#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7, n, mi = 1e18, a[200005], ans;
pair<long long, long long> dp[200005], s[200005], it[800005], res[200005];
void upd(long long id, long long l, long long r, long long vt,
         pair<long long, long long> z) {
  if (l > vt || r < vt) return;
  if (it[id].first > z.first)
    it[id] = z;
  else if (it[id].first == z.first)
    (it[id].second += z.second) %= mod;
  if (l == r) return;
  long long mid = (l + r) >> 1;
  upd(id * 2, l, mid, vt, z);
  upd(id * 2 + 1, mid + 1, r, vt, z);
}
pair<long long, long long> get(long long id, long long l, long long r,
                               long long u, long long v) {
  if (l > v || r < u) return {1e18, 0};
  if (u <= l && r <= v) return it[id];
  long long mid = (l + r) >> 1;
  pair<long long, long long> a = get(id * 2, l, mid, u, v);
  pair<long long, long long> b = get(id * 2 + 1, mid + 1, r, u, v);
  if (a.first == b.first)
    return {a.first, (a.second + b.second) % mod};
  else if (a.first < b.first)
    return {a.first, a.second};
  else
    return {b.first, b.second};
}
void Solve() {
  cin >> n;
  for (long long i = 1, _b = n; i <= _b; i++) cin >> s[i].second >> s[i].first;
  sort(s + 1, s + n + 1);
  for (long long i = 1, _b = n; i <= _b; i++) a[i] = s[i].first;
  for (long long i = 1, _b = 4 * n; i <= _b; i++) it[i].first = 1e18;
  for (long long i = n, _b = 1; i >= _b; i--) {
    long long pos = lower_bound(a + 1, a + n + 1, s[i].second) - a;
    if (pos > n) {
      res[i].first = s[i].first;
      res[i].second = 1;
    } else {
      pair<long long, long long> tmp = get(1, 1, n, pos, n);
      res[i] = tmp;
      res[i].first -= (s[i].second - s[i].first);
    }
    upd(1, 1, n, i, res[i]);
    if (res[i].first < mi) {
      mi = res[i].first;
      ans = res[i].second;
    } else if (res[i].first == mi)
      (ans += res[i].second) %= mod;
  }
  cout << ans;
}
int main() {
  int Test_numbers = 1;
  while (Test_numbers--) Solve();
  return 0;
}
