#include <bits/stdc++.h>
using namespace std;
int n, len;
pair<long long, long long> b[200010];
pair<pair<long long, long long>, int> a[200010];
long long d[200010], mn[450], cnt[200010], mnt[450];
long long res;
long long rn = 1e18;
long long pr[200010];
vector<pair<long long, long long> > v[450];
long long md = 1e9 + 7;
int main() {
  scanf("%d", &n);
  len = (int)sqrt(n);
  for (int i = 0; i < n; i++) scanf("%I64d%I64d", &b[i].second, &b[i].first);
  sort(b, b + n);
  for (int i = 0; i < n; i++) {
    a[i].first = b[i], swap(a[i].first.first, a[i].first.second);
    a[i].second = i;
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    pr[i] = lower_bound(b, b + n, make_pair(a[i].first.first, 0ll)) - b;
  reverse(a, a + n);
  reverse(pr, pr + n);
  fill(mn, mn + (n - 1) / len + 1, 1e18);
  for (int i = 0; i < n; i++) {
    int x = a[i].second / len, xi = pr[i] / len;
    if (pr[i] == n)
      d[i] = a[i].first.second, cnt[i] = 1;
    else {
      d[i] = 1e18;
      for (int j = 0; j < v[xi].size(); j++) {
        if (a[v[xi][j].first].first.second >= a[i].first.first) {
          if (v[xi][j].second < d[i]) d[i] = v[xi][j].second, cnt[i] = 0;
          if (v[xi][j].second == d[i])
            cnt[i] = (cnt[i] + cnt[v[xi][j].first]) % md;
        }
      }
      for (int j = xi + 1; j <= (n - 1) / len; j++) {
        if (mn[j] < d[i]) d[i] = mn[j], cnt[i] = 0;
        if (mn[j] == d[i]) cnt[i] = (cnt[i] + mnt[j]) % md;
      }
      d[i] = d[i] - a[i].first.first + a[i].first.second;
    }
    if (mn[x] > d[i]) mnt[x] = 0, mn[x] = d[i];
    if (mn[x] == d[i]) mnt[x] = (mnt[x] + cnt[i]) % md;
    v[x].push_back(make_pair(i, d[i]));
  }
  for (int i = 0; i < n; i++) rn = min(rn, d[i]);
  for (int i = 0; i < n; i++)
    if (d[i] == rn) res = (res + cnt[i]) % md;
  printf("%I64d", res);
  return 0;
}
