#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
long long n, ans;
long long f[maxn], g[maxn], minn[maxn], sum[maxn];
struct node {
  long long in, out;
  bool operator<(const node& a) const { return out < a.out; }
} a[maxn];
inline long long read() {
  char c = getchar();
  long long res = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res * f;
}
inline long long add(long long x, long long y) {
  return x + y >= mod ? x + y - mod : x + y;
}
inline long long dec(long long x, long long y) {
  return x - y < 0 ? x - y + mod : x - y;
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) a[i].out = read(), a[i].in = read();
  sort(a + 1, a + n + 1);
  long long inmax = -inf, outmin = inf;
  for (long long i = 1; i <= n; i++)
    inmax = max(inmax, a[i].in), outmin = min(outmin, a[i].out);
  for (long long i = 1; i <= n; i++)
    if (a[i].in < outmin) g[i] = 1;
  for (long long i = 1; i <= n; i++) {
    long long pos = upper_bound(a + 1, a + i, (node){2333, a[i].in}) - a - 1;
    f[i] = minn[pos] + a[i].in;
    if (!g[i]) g[i] = sum[pos];
    if (i > 1 && f[i] - a[i].out == minn[i - 1])
      sum[i] = add(sum[i - 1], g[i]);
    else if (f[i] - a[i].out < minn[i - 1] || i == 1)
      sum[i] = g[i];
    else
      sum[i] = sum[i - 1];
    minn[i] = min(minn[i - 1], f[i] - a[i].out);
  }
  long long m = inf;
  for (long long i = 1; i <= n; i++)
    if (a[i].out > inmax) m = min(m, f[i]);
  for (long long i = 1; i <= n; i++)
    if (a[i].out > inmax && f[i] == m) ans = add(ans, g[i]);
  printf("%lld", ans);
  return 0;
}
