#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > dolls;
vector<pair<int, int> > tree;
int n;
pair<int, int> merge(pair<int, int> &x, pair<int, int> &y) {
  if (x.first < y.first)
    return x;
  else if (x.first > y.first)
    return y;
  return {x.first, (x.second + y.second) % 1000000007};
}
void update(int pos, pair<int, int> val) {
  tree[pos + n] = val;
  for (int i = (pos + n) >> 1; i > 0; i >>= 1) {
    tree[i] = merge(tree[2 * i], tree[2 * i + 1]);
  }
}
pair<int, int> query(int l, int r) {
  pair<int, int> ans = {0x7FFFFFFF, 0};
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ans = merge(tree[l++], ans);
    if (r & 1) ans = merge(tree[--r], ans);
  }
  return ans;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int out, in;
    cin >> out >> in;
    dolls.push_back({out, in});
  }
  auto comp = [](const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second != b.second) return a.second < b.second;
    return a.first < b.first;
  };
  sort(dolls.begin(), dolls.end(), comp);
  tree.assign(2 * n, {0x7FFFFFFF, 0});
  for (int i = n - 1; i >= 0; i--) {
    int pos = lower_bound(dolls.begin(), dolls.end(),
                          pair<int, int>(0, dolls[i].first), comp) -
              dolls.begin();
    if (pos >= n) {
      update(i, {dolls[i].second, 1});
    } else {
      pair<int, int> best = query(pos, n);
      update(i, {best.first - (dolls[i].first - dolls[i].second), best.second});
    }
  }
  cout << query(0, n).second << endl;
  return 0;
}
