#include <bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
int n, ma, l[410000], v[410000], ll, vv, b[410000], bt, xx, al[410000],
    av[410000];
long long f[410000], ff, af[410000];
struct nod {
  int ii, oo;
  bool operator<(const nod &a) const { return ii < a.ii; }
} a[210000];
inline void upd(int x) {
  if (vv < v[x]) {
    v[x] = vv;
    f[x] = ff;
    return;
  }
  if (vv > v[x]) return;
  f[x] += ff;
  if (f[x] >= p) f[x] -= p;
}
inline void add(int x) {
  while (x <= bt) {
    upd(x);
    x += x & (-x);
  }
}
inline void getl(int x) {
  if (v[x] < vv) {
    vv = v[x];
    ff = f[x];
    return;
  }
  if (v[x] > vv) return;
  ff += f[x];
  if (ff >= p) ff -= p;
}
inline void ask(int x) {
  while (x) {
    getl(x);
    x -= x & (-x);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].oo, &a[i].ii);
    b[++bt] = a[i].ii;
    b[++bt] = a[i].oo;
  }
  b[++bt] = 0;
  sort(b + 1, b + bt + 1);
  bt = unique(b + 1, b + bt + 1) - b - 1;
  for (int i = 1; i <= bt; i++) v[i] = 0x7fffffff;
  sort(a + 1, a + n + 1);
  xx = lower_bound(b + 1, b + bt + 1, 0) - b;
  ll = 0;
  vv = 0;
  ff = 1;
  add(xx);
  for (int i = 1; i <= n; i++) {
    xx = lower_bound(b + 1, b + bt + 1, a[i].ii) - b;
    ll = -1;
    vv = ff = 0;
    ask(xx);
    ll++;
    vv += a[i].ii - a[i].oo;
    al[i] = ll;
    av[i] = vv + a[i].oo;
    af[i] = ff;
    xx = lower_bound(b + 1, b + bt + 1, a[i].oo) - b;
    add(xx);
  }
  vv = 0x7fffffff;
  ff = 0;
  ma = a[1].ii;
  for (int i = 2; i <= n; i++)
    if (a[i].ii > ma) ma = a[i].ii;
  for (int i = 1; i <= n; i++)
    if (a[i].oo > ma) {
      if (av[i] < vv) {
        vv = av[i];
        ff = af[i];
        continue;
      }
      if (av[i] > vv) continue;
      ff += af[i];
      if (ff >= p) ff -= p;
    }
  printf("%I64d\n", ff);
}
