#include <bits/stdc++.h>
using namespace std;
int n, a[200005], b[200005];
vector<int> za;
struct seg {
  pair<int, int> seg[(1 << 20)];
  pair<int, int> mergee(pair<int, int> a, pair<int, int> b) {
    if (a.first < b.first) return a;
    if (a.first > b.first) return b;
    return make_pair(a.first, (a.second + b.second) % 1000000007);
  }
  void init() { fill(seg, seg + (1 << 20), make_pair(2 * 1000000000, 0)); }
  void update(int pos, pair<int, int> p) {
    pos += (1 << 19) - 1;
    seg[pos] = mergee(seg[pos], p);
    while (pos) {
      pos = (pos - 1) / 2;
      seg[pos] = mergee(seg[pos * 2 + 1], seg[pos * 2 + 2]);
    }
  }
  pair<int, int> query(int a, int b, int k, int l, int r) {
    if (r < a || b < l) return make_pair(2 * 1000000000, 0);
    if (a <= l && r <= b) return seg[k];
    return mergee(query(a, b, k * 2 + 1, l, (l + r) / 2),
                  query(a, b, k * 2 + 2, (l + r) / 2 + 1, r));
  }
} kaede;
int main() {
  cin >> n;
  kaede.init();
  vector<pair<int, int> > vec;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    za.push_back(a[i]);
    za.push_back(b[i]);
    vec.push_back(pair<int, int>(a[i], b[i]));
  }
  sort(za.begin(), za.end());
  za.erase(unique(za.begin(), za.end()), za.end());
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    int x = (lower_bound(za.begin(), za.end(), vec[i].first) - za.begin());
    int y = (lower_bound(za.begin(), za.end(), vec[i].second) - za.begin());
    pair<int, int> a = kaede.query(x, za.size() - 1, 0, 0, (1 << 19) - 1);
    if (a.first == 2 * 1000000000) {
      kaede.update(y, make_pair(vec[i].second, 1));
    } else {
      kaede.update(y,
                   make_pair(a.first - vec[i].first + vec[i].second, a.second));
    }
  }
  cout << kaede.seg[0].second << endl;
}
