#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
long long p = 1e9 + 7;
pair<long long, long long> a[maxn];
long long dp[maxn], cnt[maxn];
int n;
int main() {
  while (cin >> n) {
    for (int i = 1; i <= n; i++) {
      scanf("%lld%lld", &a[i].second, &a[i].first);
    }
    a[n + 1].first = 1e9 + 7;
    sort(a + 1, a + 1 + n);
    dp[n + 1] = 1e9 + 7;
    for (int i = n; i > 0; i--) {
      int id = lower_bound(
                   a + i, a + n + 1,
                   (pair<long long, long long>){a[i].second, (long long)-1}) -
               a;
      if (id == n + 1) {
        dp[i] = a[i].first;
        cnt[i] = 1;
      } else {
        dp[i] = dp[id] - a[i].second + a[i].first;
        cnt[i] = cnt[id];
      }
      if (dp[i] > dp[i + 1]) {
        dp[i] = dp[i + 1];
        cnt[i] = cnt[i + 1];
      } else if (dp[i] == dp[i + 1]) {
        cnt[i] = (cnt[i] + cnt[i + 1]) % p;
      }
    }
    printf("%lld\n", cnt[1]);
  }
}
