#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
  node(int x = 0, int y = 0) : x(x), y(y) {}
  inline bool operator<(const node& a) const {
    if (y != a.y) return y < a.y;
    return x < a.x;
  }
} a[200003];
int out[200003], f[200003], g[200003], s[200003], r[200003];
int maxx, miny = 0x3f3f3f3f, ans, n;
inline void read(int& x) {
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
}
void print(int x) {
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
inline int add(int x, int y) {
  return x + y >= 1000000007 ? x + y - 1000000007 : x + y;
}
inline int dec(int x, int y) { return x < y ? x - y + 1000000007 : x - y; }
int main() {
  int x, y, tmp;
  read(n);
  for (register int i = 1; i <= n; ++i) {
    read(y), read(x);
    maxx = max(maxx, x);
    miny = min(miny, y);
    a[i] = node(x, y);
  }
  sort(a + 1, a + 1 + n);
  for (register int i = 1; i <= n; ++i) out[i] = a[i].y;
  for (register int i = 1; i <= n; ++i)
    if (a[i].x < miny) g[i] = 1;
  tmp = 0x3f3f3f3f;
  for (register int i = 1; i <= n; ++i) {
    x = upper_bound(out + 1, out + 1 + n, a[i].x) - out - 1;
    f[i] = s[x] + a[i].x;
    if (g[i] == 0) g[i] = r[x];
    y = f[i] - a[i].y;
    if (y == s[i - 1] && i != 1)
      r[i] = add(g[i], r[i - 1]);
    else if (y < s[i - 1] || i == 1)
      r[i] = g[i];
    else
      r[i] = r[i - 1];
    s[i] = min(s[i - 1], y);
    if (a[i].y > maxx) tmp = min(tmp, f[i]);
  }
  for (register int i = 1; i <= n; ++i)
    if (a[i].y > maxx && f[i] == tmp) ans = add(ans, g[i]);
  print(ans);
  return 0;
}
