#include <bits/stdc++.h>
using namespace std;
long long int binomialCoeff(long long int n, long long int k) {
  long long int res = 1;
  if (k > n - k) k = n - k;
  for (int i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
long long int power(long long int x, long long int y, long long int mod = 0) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2, mod);
  if (!mod) {
    if (y % 2)
      return temp * temp;
    else
      return temp * temp * x;
  }
  if (y % 2 == 0)
    return (temp * temp) % mod;
  else
    return (((x * temp) % mod) * temp) % mod;
}
vector<long long int> primes;
void Sieve(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p]) primes.push_back(p);
}
const int N = 4e5 + 5;
pair<long long int, long long int> tree[4 * N];
long long int mod = 1e9 + 7;
void build(int node, int start, int end) {
  if (start == end) {
    tree[node].first = 1e18 + 5;
    tree[node].second = 0;
    return;
  }
  int mid = (start + end) / 2;
  build(node * 2, start, mid);
  build(node * 2 + 1, mid + 1, end);
  tree[node] = {1e18 + 5, 0};
}
void update(int node, int start, int end, int ind, long long int val,
            long long int cnt) {
  if (start > end) return;
  if (start == end) {
    if (tree[node].first == val) {
      tree[node].second = (tree[node].second + cnt) % mod;
    } else if (tree[node].first > val) {
      tree[node].first = val;
      tree[node].second = cnt;
    }
    return;
  }
  int mid = (start + end) / 2;
  if (ind <= mid)
    update(2 * node, start, mid, ind, val, cnt);
  else
    update(2 * node + 1, mid + 1, end, ind, val, cnt);
  tree[node].first = min(tree[node * 2].first, tree[node * 2 + 1].first);
  if (tree[node * 2].first == tree[node * 2 + 1].first)
    tree[node].second =
        (tree[node * 2].second + tree[node * 2 + 1].second) % mod;
  else if (tree[node * 2].first < tree[node * 2 + 1].first)
    tree[node].second = tree[node * 2].second;
  else
    tree[node].second = tree[node * 2 + 1].second;
}
pair<long long int, long long int> get(int node, int start, int end, int l,
                                       int r) {
  pair<long long int, long long int> res;
  if (start > end || start > r || end < l) {
    res.first = 1e18 + 5;
    res.second = 0;
    return res;
  }
  if (start >= l && end <= r) return tree[node];
  int mid = (start + end) / 2;
  auto a = get(2 * node, start, mid, l, r);
  auto b = get(2 * node + 1, mid + 1, end, l, r);
  if (a.first == b.first) {
    res.first = a.first;
    res.second = (a.second + b.second) % mod;
    return res;
  }
  if (a.first < b.first)
    return a;
  else
    return b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  pair<long long int, long long int> arr[n];
  map<long long int, long long int> comp;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first >> arr[i].second;
    comp[arr[i].first] = 1;
    comp[arr[i].second] = 1;
  }
  sort(arr, arr + n);
  int ind = 1;
  for (auto x : comp) {
    comp[x.first] = ind;
    ind++;
  }
  long long int ans = 0;
  long long int inf = 1e18 + 5;
  build(1, 1, ind);
  for (int i = n - 1; i >= 0; i--) {
    long long int in = arr[i].second;
    long long int out = arr[i].first;
    auto it = get(1, 1, ind, comp[out], ind);
    if (it.first == inf) {
      update(1, 1, ind, comp[in], in, 1);
      continue;
    }
    long long int cnt = it.second;
    long long int sp = it.first;
    long long int nsp = it.first + in - out;
    update(1, 1, ind, comp[in], nsp, cnt);
  }
  auto it = get(1, 1, ind, 1, ind);
  ans = it.second;
  cout << ans;
}
