#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int infi = 2147483600;
const long long infl = 1e17;
struct SegmentTree {
 private:
  int N;
  vector<long long> node;
  long long e;

 public:
  SegmentTree() {}
  SegmentTree(long long e) : e(e) {}
  void __init__(int sz) {
    N = 1;
    while (N < sz) N *= 2;
    node.resize(2 * N - 1, e);
  }
  void build(vector<long long> &v) {
    int sz = int(v.size());
    __init__(sz);
    for (long long i = 0; i < (long long)sz; i++) {
      node[i + N - 1] = v[i];
    }
    for (int i = N - 2; i >= 0; i--) {
      node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }
  void update(int k, long long x) {
    k += N - 1;
    node[k] = x;
    while (k > 0) {
      k = (k - 1) / 2;
      node[k] = min(node[2 * k + 1], node[2 * k + 2]);
    }
  }
  void renew(int b, int e, long long x) {
    renew(b, e, 0, 0, N, x);
    return;
  }
  void renew(int b, int e, int k, int l, int r, long long x) {
    if (e <= 0 || b >= N) return;
    if (k > 0) {
      node[k] = min(node[k], node[(k - 1) / 2]);
    }
    if (r < b || e < l) return;
    if (b <= l && r <= e) {
      node[k] = min(node[k], x);
      return;
    } else if (k < N - 1) {
      renew(b, e, 2 * k + 1, l, (l + r) / 2, x);
      renew(b, e, 2 * k + 2, (l + r) / 2, r, x);
      return;
    }
    return;
  }
  long long get(int i) {
    int k = i + N - 1;
    long long res = node[k];
    while (k > 0) {
      k = (k - 1) / 2;
      res = min(res, node[k]);
    }
    return res;
  }
  long long query(int a, int b) { return query(a, b, 0, 0, N); }
  long long query(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a) return e;
    if (a <= l && r <= b) return node[k];
    long long vl, vr;
    vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
  void recalc() {
    for (long long k = 0; k < (long long)N - 1; k++) {
      node[2 * k + 1] = min(node[2 * k * 1], node[k]);
      node[2 * k + 2] = min(node[2 * k * 2], node[k]);
    }
  }
  long long show_one(int i) { return node[i + N - 1]; }
  void show() {
    for (long long i = 0; i < (long long)N; i++) cout << node[i] << " ";
    cout << endl;
    return;
  }
};
SegmentTree seg(infl);
bool compare(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first < b.first;
}
long long calc_idx(vector<long long> &idx, long long x) {
  long long MIN = 0, MAX = idx.size();
  while (MIN + 1 != MAX) {
    if (idx[(MIN + MAX) / 2] >= x) {
      MIN = (MIN + MAX) / 2;
    } else {
      MAX = (MIN + MAX) / 2;
    }
  }
  return idx[MIN];
}
int main() {
  int n;
  cin >> n;
  vector<pair<long long, long long> > doll(n);
  for (long long i = 0; i < (long long)n; i++) {
    long long x, y;
    cin >> y >> x;
    doll[i] = make_pair(x, y);
  }
  sort((doll).begin(), (doll).end(), compare);
  vector<long long> inner(n);
  for (long long i = 0; i < (long long)n; i++) inner[i] = doll[i].first;
  map<long long, long long> Sum;
  map<long long, vector<long long> > idx_save;
  vector<long long> dp(n, 0);
  seg.__init__(n);
  for (long long i = (long long)n - 1; i > (long long)-1; i--) {
    long long idx =
        lower_bound((inner).begin(), (inner).end(), doll[i].second) -
        inner.begin();
    if (idx == n) {
      dp[i] = doll[i].first;
      seg.update(i, doll[i].first);
      long long idx_now;
      if (idx_save[dp[i]].empty()) {
        idx_now = i;
      } else {
        idx_now = idx_save[dp[i]][idx_save[dp[i]].size() - 1];
      }
      Sum[i] = (Sum[idx_now] + 1) % mod;
      idx_save[dp[i]].push_back(i);
      continue;
    }
    long long dj = seg.query(idx, n);
    dp[i] = dj - (doll[i].second - doll[i].first);
    seg.update(i, dp[i]);
    long long idx_dpi, idx_dj;
    if (idx_save[dp[i]].empty()) {
      idx_dpi = i;
    } else
      idx_dpi = idx_save[dp[i]][idx_save[dp[i]].size() - 1];
    idx_dj = calc_idx(idx_save[dj], idx);
    Sum[i] = (Sum[idx_dpi] + Sum[idx_dj]) % mod;
    idx_save[dp[i]].push_back(i);
  }
  long long res = seg.query(0, n);
  long long idx_res = idx_save[res][idx_save[res].size() - 1];
  cout << Sum[idx_res] % mod << endl;
}
