#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const int BIG = 1e9 + 555;
const int maxN = 200 * 1000 + 9;
pair<long long, long long> segTree[maxN * 4];
int n;
pair<long long, long long> doll[maxN];
vector<long long> vv;
void minimize(pair<long long, long long> &a, pair<long long, long long> b) {
  if (b.first < a.first) {
    a = b;
  } else if (b.first == a.first) {
    a.second = (a.second + b.second) % MOD;
  }
}
void upd(int id, int l, int r, int idx, pair<long long, long long> v) {
  if (l == idx && r == idx) {
    segTree[id] = v;
    return;
  }
  if (r < idx || l > idx) {
    return;
  }
  int mid = (l + r) / 2;
  upd(id * 2, l, mid, idx, v);
  upd(id * 2 + 1, mid + 1, r, idx, v);
  pair<long long, long long> ans = make_pair(INF, 0);
  minimize(ans, segTree[id * 2]);
  minimize(ans, segTree[id * 2 + 1]);
  segTree[id] = ans;
}
void upd(int idx, pair<long long, long long> v) { upd(1, 0, n - 1, idx, v); }
pair<long long, long long> query(int id, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    return segTree[id];
  }
  if (r < L || l > R) {
    return make_pair(INF, 0);
  }
  pair<long long, long long> ans = make_pair(INF, 0);
  int mid = (l + r) / 2;
  minimize(ans, query(id * 2, l, mid, L, R));
  minimize(ans, query(id * 2 + 1, mid + 1, r, L, R));
  return ans;
}
pair<long long, long long> query(int l, int r) {
  return query(1, 0, n - 1, l, r);
}
void init() {
  for (int i = 0; i < maxN * 4; i++) {
    segTree[i] = make_pair(INF, 0);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  init();
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long in, out;
    cin >> out >> in;
    doll[i] = make_pair(in, out);
  }
  sort(doll, doll + n);
  vv.resize(n);
  for (int i = 0; i < n; i++) {
    vv[i] = doll[i].first;
  }
  for (int i = n - 1; i >= 0; i--) {
    int j = lower_bound(vv.begin(), vv.end(), doll[i].second) - vv.begin();
    if (j >= n) {
      upd(i, make_pair(doll[i].first, 1));
      continue;
    }
    pair<long long, long long> foo = query(j, n - 1);
    foo.first += (doll[i].first - doll[i].second);
    upd(i, foo);
  }
  cout << query(0, n - 1).second << '\n';
  return 0;
}
