#include <bits/stdc++.h>
using namespace std;
long long const MOD = int(1e9) + 7;
const int N = 500000 + 500;
pair<long long, long long> tree[4 * N];
pair<long long, long long> combine(pair<long long, long long> a,
                                   pair<long long, long long> b) {
  pair<long long, long long> temp;
  if (a.first == b.first) {
    temp.first = a.first;
    temp.second = (a.second + b.second) % MOD;
  } else if (a.first < b.first) {
    temp = a;
  } else {
    temp = b;
  }
  return temp;
}
void updatePoint(long long node, long long l, long long r, long long who,
                 pair<long long, long long> val) {
  if (l > r || who < l || who > r) return;
  if (l == r) {
    tree[node] = combine(tree[node], val);
    return;
  }
  long long mid = (l + r) / 2LL;
  updatePoint(node + node, l, mid, who, val);
  updatePoint(node + node + 1, mid + 1, r, who, val);
  tree[node] = combine(tree[node + node], tree[node + node + 1]);
}
pair<long long, long long> query(long long node, long long l, long long r,
                                 long long a, long long b) {
  if (l > r || a > b || l > b || r < a) return make_pair(1e18, 0);
  if (a <= l && r <= b) return tree[node];
  long long mid = (l + r) / 2LL;
  return combine(query(node + node, l, mid, a, b),
                 query(node + node + 1, mid + 1, r, a, b));
}
int main(void) {
  int n;
  cin >> n;
  pair<int, int> arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i].second >> arr[i].first;
  sort(arr, arr + n);
  set<long long> unique;
  for (int i = 0; i < n; i++) {
    unique.insert(arr[i].first);
    unique.insert(arr[i].second);
  }
  map<long long, long long> hashedTo;
  map<long long, long long> reverseHash;
  long long cnt = 0;
  for (auto it : unique) {
    hashedTo[it] = cnt++;
    reverseHash[cnt - 1] = it;
  }
  cnt--;
  for (int i = 0; i < 4 * N; i++) {
    tree[i] = make_pair(1e18, 0);
  }
  updatePoint(1, 0, cnt, hashedTo[arr[n - 1].first],
              make_pair(arr[n - 1].first, 1));
  long long ans = arr[n - 1].first;
  long long ways = 1;
  for (int i = n - 2; i >= 0; i--) {
    pair<long long, long long> temp =
        query(1, 0, cnt, hashedTo[arr[i].second], cnt);
    if (temp.first != 1e18)
      temp.first = temp.first - (arr[i].second - arr[i].first);
    else {
      temp.first = arr[i].first;
      temp.second = 1LL;
    }
    if (temp.first < ans) {
      ans = temp.first;
      ways = temp.second;
    } else if (temp.first == ans) {
      ways = (ways + temp.second) % MOD;
    }
    updatePoint(1, 0, cnt, hashedTo[arr[i].first], temp);
  }
  cout << ways << endl;
  return 0;
}
