#include <bits/stdc++.h>
using namespace std;
const int N = 200005, mod = 1e9 + 7;
struct node {
  int in, out;
} a[N];
int n, min_out = 1e9, max_in, sum = 1e9, ans, f[N], ff[N], g[N], gg[N];
bool cmp(node a, node b) {
  if (a.out == b.out)
    return a.in < b.in;
  else
    return a.out < b.out;
}
int calc(int x) {
  int l = 1, r = n, res = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (a[mid].out <= x) {
      res = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].out, &a[i].in);
    min_out = min(min_out, a[i].out);
    max_in = max(max_in, a[i].in);
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++)
    if (a[i].in < min_out) g[i] = 1;
  for (int i = 1; i <= n; i++) {
    int tmp = calc(a[i].in);
    f[i] = ff[tmp] + a[i].in;
    if (!g[i]) g[i] = gg[tmp];
    int x = f[i] - a[i].out;
    if (x < ff[i - 1] || i == 1)
      gg[i] = g[i];
    else if (x == ff[i - 1])
      gg[i] = (g[i] + gg[i - 1]) % mod;
    else
      gg[i] = gg[i - 1];
    ff[i] = min(ff[i - 1], x);
    if (a[i].out > max_in) {
      if (sum > f[i]) {
        sum = f[i];
        ans = g[i];
      } else if (sum == f[i])
        ans = (ans + g[i]) % mod;
    }
  }
  printf("%d", ans);
  return 0;
}
