#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
int n;
long long dp[2][200005][2];
struct node
{
int x,y;
node(){};
node(int xx,int yy)
{
x=xx;y=yy;
}
friend bool operator<(node a,node b)
{
if(a.y==b.y)
return a.x<b.x;
else
return a.y<b.y;
}
}itm[200005];
long long mod=1e9+7;
void update(long long dp1[],long long dp2[],long long v)
{
if(dp1[0]+v > dp2[0])
{
dp2[0] = dp1[0]+v;
dp2[1] = dp1[1];
}
else if(dp1[0]+v == dp2[0])
dp2[1] += dp1[1];
dp2[1]%=mod;
}
int main() {
while(~scanf("%d",&n))
{
int maxnx=0;
for(int i=0;i<n;i++)
{
scanf("%d%d",&itm[i].y,&itm[i].x);
maxnx = max(itm[i].x,maxnx);
}
sort(itm,itm+n);
memset(dp,0,sizeof(dp));
long long maxn = 1e9+7;
for(int i=0;i<n;i++)
{
dp[0][i][0]=itm[i].y-itm[i].x;
dp[0][i][1]=1;
if(i!=0)
update(dp[1][i-1],dp[1][i],0);
node tp(itm[i].x,itm[i].x);
int id=upper_bound(itm,itm+i,tp)-itm;
if(id!=0)
{
id--;
update(dp[1][id],dp[0][i],(itm[i].y-itm[i].x));
}
update(dp[0][i],dp[1][i],0);
if(itm[i].y>maxnx)
maxn = min(maxn,itm[i].y-dp[0][i][0]);
}
long long ans=0;
for(int i=0;i<n;i++)
{
//cout<<itm[i].y<<" "<<dp[0][i][0]<<" "<<dp[0][i][1]<<endl;
if((itm[i].y-dp[0][i][0]) == maxn && itm[i].y>maxnx)
{
ans+=dp[0][i][1];
ans%=mod;
}
}
printf("%lld\n",ans);
}
return 0;
}