#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int maxi[200005];
pair<long long int, long long int> vals[200005];
long long int moves[200005];
long long int larg[200005];
map<long long int, long long int> mp;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  vector<long long int> x(3, 0);
  vector<vector<long long int> > v;
  vector<pair<long long int, long long int> > z;
  z.push_back(make_pair(0, 0));
  for (long long int i = 1; i <= n; i++) {
    long long int a, b;
    cin >> a >> b;
    z.push_back(make_pair(a, b));
  }
  sort(z.begin(), z.end());
  for (long long int i = 1; i <= n; i++) {
    long long int a = z[i].first;
    long long int b = z[i].second;
    vals[i] = make_pair(a, b);
    x[0] = a;
    x[1] = 0;
    x[2] = b;
    v.push_back(x);
    x[0] = b;
    x[1] = 1;
    x[2] = i;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  long long int ans = 0;
  set<long long int> s;
  long long int mini = 10000000000;
  for (long long int i = n; i >= 1; i--) {
    larg[i] = max(larg[i + 1], vals[i].second);
  }
  long long int i = 1;
  set<long long int>::iterator it;
  for (long long int j = 0; j < v.size(); j++) {
    if (v[j][1]) {
      long long int u = vals[v[j][2]].first - vals[v[j][2]].second;
      long long int mo = 0;
      if (s.size()) {
        it = s.end();
        it--;
        mo = mp[*it];
        u += *it;
        maxi[v[j][2]] = u;
        moves[v[j][2]] = mo;
      } else {
        mo = 1;
        maxi[v[j][2]] = u;
        moves[v[j][2]] = mo;
      }
    } else {
      s.insert(maxi[i]);
      mp[maxi[i]] += moves[i];
      mp[maxi[i]] %= mod;
      if (larg[i + 1] < vals[i].first) {
        mini = min(mini, vals[i].first - maxi[i]);
      }
      i++;
    }
  }
  for (long long int i = n; i >= 1; i--) {
    if (larg[i + 1] >= vals[i].first) {
      break;
    }
    if (vals[i].first - maxi[i] == mini) {
      ans += moves[i];
      ans %= mod;
    }
  }
  cout << ans;
}
