#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
pair<int, int> a[N];
int n;
vector<int> vc, b;
inline int get(int x) {
  return lower_bound(vc.begin(), vc.end(), x) - vc.begin() + 1;
}
inline int f(int x) { return vc[x - 1]; }
struct Node {
  long long v, cnt;
} bit[N * 2];
inline void add(int x, long long v, long long cnt) {
  while (x < N * 2) {
    if (bit[x].v > v)
      bit[x].v = v, bit[x].cnt = cnt;
    else if (bit[x].v == v)
      (bit[x].cnt += cnt) %= MOD;
    x += x & -x;
  }
}
inline Node sum(int x) {
  Node tmp;
  tmp.v = tmp.cnt = 0;
  while (x) {
    if (bit[x].v < tmp.v)
      tmp = bit[x];
    else if (bit[x].v == tmp.v)
      (tmp.cnt += bit[x].cnt) %= MOD;
    x -= x & -x;
  }
  return tmp;
}
map<long long, long long> mp;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d %d", &a[i].first, &a[i].second), vc.emplace_back(a[i].first),
        vc.emplace_back(a[i].second), b.emplace_back(a[i].second);
  sort(vc.begin(), vc.end());
  sort(b.begin(), b.end());
  vc.erase(unique(vc.begin(), vc.end()), vc.end());
  for (int i = 1; i <= n; ++i)
    a[i].first = get(a[i].first), a[i].second = get(a[i].second);
  sort(a + 1, a + 1 + n);
  add(1, 0, 1);
  for (int i = 1; i <= n; ++i) {
    Node tmp = sum(a[i].second);
    add(a[i].first, tmp.v + f(a[i].second) - f(a[i].first), tmp.cnt);
    if (lower_bound(b.begin(), b.end(), f(a[i].first)) == b.end()) {
      (mp[tmp.v + f(a[i].second)] += tmp.cnt) %= MOD;
    }
  }
  printf("%lld\n", (*mp.begin()).second);
  return 0;
}
