#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int INF = 1e9 + 100;
int n;
pair<int, int> doll[200010];
pair<int, int> T[200010 * 4];
pair<int, int> merg(pair<int, int> lf, pair<int, int> rt) {
  if (lf.first < rt.first) return lf;
  if (lf.first > rt.first) return rt;
  return make_pair(lf.first,
                   ((long long)lf.second + (long long)rt.second) % mod);
}
void update(int id, int l, int r, int ql, int qr, int minVal, int minNum) {
  if (r < ql || qr < l) return;
  if (ql <= l && r <= qr) {
    T[id].first = minVal;
    T[id].second = minNum;
    return;
  }
  int mid = (l + r) >> 1;
  update(id << 1, l, mid, ql, qr, minVal, minNum);
  update(id << 1 | 1, mid + 1, r, ql, qr, minVal, minNum);
  T[id] = merg(T[id << 1], T[id << 1 | 1]);
}
pair<int, int> get(int id, int l, int r, int ql, int qr) {
  if (r < ql || qr < l) return make_pair(INF, 0);
  if (ql <= l && r <= qr) return T[id];
  int mid = (l + r) >> 1;
  pair<int, int> lf = get(id << 1, l, mid, ql, qr);
  pair<int, int> rt = get(id << 1 | 1, mid + 1, r, ql, qr);
  return merg(lf, rt);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> doll[i].second >> doll[i].first;
  sort(doll + 1, doll + n + 1);
  doll[n + 1].first = 0;
  for (int i = 1; i <= 4 * n; i++) T[i] = make_pair(INF, 0);
  for (int i = n; i >= 1; i--) {
    int lo, hi, mid, res;
    lo = i + 1;
    hi = n;
    res = -1;
    while (lo <= hi) {
      mid = (lo + hi) >> 1;
      if (doll[mid].first >= doll[i].second) {
        res = mid;
        hi = mid - 1;
      } else
        lo = mid + 1;
    }
    if (res == -1)
      update(1, 1, n, i, i, doll[i].first, 1);
    else {
      pair<int, int> p = get(1, 1, n, res, n);
      update(1, 1, n, i, i, p.first - (doll[i].second - doll[i].first),
             p.second);
    }
  }
  pair<int, int> p = get(1, 1, n, 1, n);
  cout << p.second;
  return 0;
}
