#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const long long INF = 1e18;
const int MAXN = 2e5 + 1;
const int mod = 1e9 + 7;
pair<int, int> t[4 * MAXN];
pair<int, int> get_v(pair<int, int> a, pair<int, int> b) {
  if (a.first < b.first)
    return a;
  else if (a.first > b.first)
    return b;
  else
    return {a.first, (a.second + b.second) % mod};
}
void upd(int v, int l, int r, int p, pair<int, int> nv) {
  if (l == r)
    t[v] = nv;
  else {
    int m = (l + r) / 2;
    if (p <= m)
      upd(v * 2, l, m, p, nv);
    else
      upd(v * 2 + 1, m + 1, r, p, nv);
    t[v] = get_v(t[v * 2], t[v * 2 + 1]);
  }
}
pair<int, int> get_min(int v, int l, int r, int ql, int qr) {
  if (ql > qr) return {2e9, 0};
  if (l == ql and r == qr) return t[v];
  int m = (l + r) / 2;
  return get_v(get_min(v * 2, l, m, ql, min(qr, m)),
               get_min(v * 2 + 1, m + 1, r, max(m + 1, ql), qr));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  pair<int, int> a[n];
  for (auto &i : a) cin >> i.second >> i.first;
  sort((a), (a) + (n));
  for (int i = n - 1; i >= 0; i--) {
    int p = lower_bound((a), (a) + (n), make_pair(a[i].second, 0)) - a;
    if (p == n)
      upd(1, 0, n - 1, i, {a[i].first, 1});
    else {
      pair<int, int> t = get_min(1, 0, n - 1, p, n - 1);
      upd(1, 0, n - 1, i, {t.first - (a[i].second - a[i].first), t.second});
    }
  }
  cout << get_min(1, 0, n - 1, 0, n - 1).second;
  return 0;
}
