#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int a[maxn], b[maxn], q[maxn], p[maxn], f[maxn], g[maxn], maxb;
bool cmp1(int i, int j) { return a[i] < a[j]; }
bool cmp2(int i, int j) { return b[i] < b[j]; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    maxb = max(maxb, b[i]);
    p[i] = q[i] = i;
  }
  sort(p + 1, p + 1 + n, cmp1);
  sort(q + 1, q + 1 + n, cmp2);
  int j = 1;
  int mn = 0, gg = 1;
  for (int k = 1; k <= n; k++) {
    int i = q[k];
    while (j <= n && a[p[j]] <= b[i]) {
      int u = p[j++];
      if (f[u] - a[u] < mn) mn = f[u] - a[u], gg = 0;
      if (f[u] - a[u] == mn) gg = (g[u] + gg) % mod;
    }
    f[i] = mn + b[i];
    g[i] = gg;
  }
  mn = 0x3f3f3f3f, gg = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] <= maxb) continue;
    if (f[i] < mn) mn = f[i], gg = 0;
    if (f[i] == mn) gg = (gg + g[i]) % mod;
  }
  printf("%d\n", gg);
  return 0;
}
