#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const long long INF = 1e15;
int n;
pair<int, int> a[N], b[N];
pair<long long, int> f[N], res;
void Add(pair<long long, int> &x, pair<long long, int> y) {
  if (x.first == y.first) (x.second += y.second) %= mod;
  if (x.first > y.first) x = y;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].second, &a[i].first);
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++)
    b[i] = {a[i].second, i}, f[i] = {(long long)(a[i].first), 1};
  sort(b + 1, b + 1 + n);
  int j = 1;
  pair<long long, int> cur = {INF, 0};
  res = {INF, 0};
  for (int i = 1; i <= n; i++) {
    while (j <= n && b[j].first <= a[i].first) {
      pair<long long, int> tmp = f[b[j].second];
      tmp.first -= a[b[j].second].second;
      Add(cur, tmp);
      j++;
    }
    f[i] = min(f[i], {cur.first + a[i].first, cur.second});
    if (a[i].second > a[n].first) Add(res, f[i]);
  }
  cout << res.second;
}
