#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MAXN = 200007;
vector<pair<long long, long long> > vp;
long long bam[MAXN];
pair<long long, long long> dp[MAXN];
bool flag[MAXN];
pair<long long, long long> solve(long long ps) {
  if (ps == -1) return pair<long long, long long>(0, 1);
  if (flag[ps]) return dp[ps];
  flag[ps] = 1;
  pair<long long, long long> p1 = solve(bam[ps]);
  p1.first += vp[ps].second - vp[ps].first;
  pair<long long, long long> p2 = solve(ps - 1);
  if (p1.first != p2.first) return dp[ps] = min(p1, p2);
  p1.second += p2.second;
  if (p1.second >= MOD) p1.second -= MOD;
  return dp[ps] = p1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  long long mxin = -1;
  vp.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> vp[i].first >> vp[i].second;
    mxin = max(mxin, vp[i].second);
  }
  sort(vp.begin(), vp.end());
  for (long long i = 0; i < n; i++) {
    bam[i] = upper_bound(vp.begin(), vp.end(),
                         pair<long long, long long>(vp[i].second, MOD)) -
             vp.begin();
    bam[i]--;
  }
  pair<long long, long long> ans(MOD, 0);
  for (long long i = 0; i < n; i++) {
    if (vp[i].first <= mxin) continue;
    pair<long long, long long> rt = solve(bam[i]);
    rt.first += vp[i].second;
    if (rt.first < ans.first)
      ans = rt;
    else if (rt.first == ans.first) {
      ans.second += rt.second;
      if (ans.second >= MOD) ans.second -= MOD;
    }
  }
  ans.second = (ans.second % MOD + MOD) % MOD;
  cout << ans.second << "\n";
  return 0;
}
