#include <bits/stdc++.h>
using namespace std;
template <typename T>
void gi(T &angka) {
  angka = 0;
  char input = getchar();
  T kali = 1;
  while (!(48 <= input && input <= 57)) {
    if (input == '-') kali = -1;
    input = getchar();
  }
  while (48 <= input && input <= 57)
    angka = (angka << 3) + (angka << 1) + input - 48, input = getchar();
  angka *= kali;
}
template <typename T1, typename T2>
void gi(T1 &angka1, T2 &angka2) {
  gi(angka1);
  gi(angka2);
}
const int MAXN = 200000;
int n;
pair<int, int> arr[MAXN + 5];
void readInput() {
  gi(n);
  for (int i = 0; i < n; ++i) {
    gi(arr[i].second, arr[i].first);
  }
}
int nxt[MAXN + 5];
int lastStart;
void findNext() {
  lastStart = n - 1;
  for (int i = 0; i < n; ++i) {
    int lo = i + 1;
    int hi = n - 1;
    int mid;
    while (lo <= hi) {
      mid = (lo + hi) >> 1;
      if (arr[mid].first >= arr[i].second) {
        hi = mid - 1;
      } else {
        lo = mid + 1;
      }
    }
    nxt[i] = lo;
    lastStart = min(lastStart, nxt[i] - 1);
  }
}
const long long mods = 1000000007LL;
struct M {
  long long x;
  M() { x = 0; }
  M(long long num) {
    if (num >= mods || num <= -mods) {
      num %= mods;
    }
    if (num < 0) {
      num += mods;
    }
    x = num;
  }
  M operator+(const M &other) const { return M(x + other.x); }
  M operator*(const M &other) const { return M(x * other.x); }
  M operator-(const M &other) const { return M(x - other.x); }
};
M cara[MAXN + 5];
long long dp[MAXN + 5];
const long long INF = 3e9;
void update(int i, int j, long long waste) {
  if (dp[i] > waste) {
    dp[i] = waste;
    cara[i] = 0;
  }
  if (dp[i] == waste) {
    cara[i] = cara[i] + cara[j];
  }
}
void bottomUp() {
  dp[n] = 3e9;
  for (int i = n - 1; i >= 0; --i) {
    dp[i] = INF;
    cara[i] = 0;
    if (nxt[i] == n) {
      cara[i] = 1;
      if (i <= lastStart) {
        dp[i] = arr[i].first;
      } else {
        dp[i] = 0;
      }
    }
    if (nxt[i] != n) {
      if (i <= lastStart) {
        update(i, nxt[i],
               dp[nxt[i]] + arr[i].first + arr[nxt[i]].first - arr[i].second);
      } else {
        update(i, nxt[i], dp[nxt[i]] + arr[nxt[i]].first - arr[i].second);
      }
    }
    if (i != lastStart) {
      if (i <= lastStart) {
        update(i, i + 1, dp[i + 1]);
      } else {
        update(i, i + 1, dp[i + 1] + arr[i + 1].first - arr[i].first);
      }
    }
  }
}
void solve() {
  sort(arr, arr + n);
  arr[n] = make_pair(3e9, 3e9);
  findNext();
  bottomUp();
  M ans = cara[0];
  cout << ans.x << endl;
}
int main() {
  int tc;
  tc = 1;
  while (tc--) {
    readInput();
    solve();
  }
}
