#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
struct data {
  int a, b;
} s[200005];
bool cmp(data x, data y) { return x.a < y.a; }
long long g0[200005], f0[200005], g[200005], f[200005];
int main() {
  int n = 0, mna = 2e9, mxb = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &s[i].a, &s[i].b);
    mna = min(mna, s[i].a);
    mxb = max(mxb, s[i].b);
  }
  sort(s + 1, s + n + 1, cmp);
  for (int i = 1; i <= n; i++)
    if (s[i].b < mna) f[i] = 1;
  g[1] = s[1].b, g0[1] = g[1] - s[1].a, f0[1] = f[1];
  for (int i = 2; i <= n; i++) {
    int l = 0, r = i;
    while (l + 1 < r) {
      int mid = (l + r) >> 1;
      if (s[mid].a <= s[i].b)
        l = mid;
      else
        r = mid;
    }
    if (l == 0)
      g[i] = s[i].b;
    else if (s[i].b < g0[l] + s[i].b)
      g[i] = s[i].b;
    else
      g[i] = g0[l] + s[i].b, f[i] = (f[i] + f0[l]) % mod;
    if (g[i] - s[i].a < g0[i - 1])
      g0[i] = g[i] - s[i].a, f0[i] = f[i];
    else if (g[i] - s[i].a == g0[i - 1])
      g0[i] = g0[i - 1], f0[i] = (f0[i - 1] + f[i]) % mod;
    else
      g0[i] = g0[i - 1], f0[i] = f0[i - 1];
  }
  long long mn = 9e18;
  for (int i = 1; i <= n; i++)
    if (s[i].a > mxb) mn = min(mn, g[i]);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (s[i].a > mxb && g[i] == mn) ans = (ans + f[i]) % mod;
  printf("%I64d", ans);
  return 0;
}
