#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
int n;
int a[200005], b[200005], c[200005], dp[200005];
int A[200005], B[200005];
int mxb;
bool mdfx1(int x, int y) { return a[x] < a[y]; }
bool mdfx2(int x, int y) { return b[x] < b[y]; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", a + i, b + i);
    A[i] = B[i] = i;
    mxb = max(mxb, b[i]);
  }
  sort(A + 1, A + n + 1, mdfx1);
  sort(B + 1, B + n + 1, mdfx2);
  int l = 1, ff = 0, sm = 1;
  for (int I = 1; I <= n; I++) {
    int i = B[I];
    while (l <= n && a[A[l]] <= b[i]) {
      int x = A[l++];
      if (c[x] - a[x] < ff) {
        ff = c[x] - a[x];
        sm = 0;
      }
      if (c[x] - a[x] == ff) {
        sm = (sm + dp[x]) % Mod;
      }
    }
    c[i] = b[i] + ff;
    dp[i] = sm;
  }
  ff = Mod;
  sm = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] > mxb) {
      if (c[i] < ff) {
        ff = c[i];
        sm = 0;
      }
      if (c[i] == ff) {
        sm = (sm + dp[i]) % Mod;
      }
    }
  }
  printf("%d\n", sm);
  return 0;
}
