#include <bits/stdc++.h>
using namespace std;
class SegTree {
 public:
  struct node {
    long long val;
    long long ct;
    node(long long x = 0, long long count = 1) {
      val = x;
      ct = count;
    }
  };
  const node REJECT_NODE = node(1e17, 0);
  long long n;
  vector<node> seg;
  vector<long long> lazy, a;
  node merge(node x, node y) {
    if (x.val < y.val)
      return x;
    else if (x.val > y.val)
      return y;
    else
      return node(x.val, (x.ct + y.ct) % 1000000007);
  }
  void apply(long long pos, pair<long long, long long> val) {
    if (val.first < seg[pos].val)
      seg[pos] = node(val.first, val.second);
    else if (val.first == seg[pos].val)
      seg[pos].ct += val.second;
    seg[pos].ct %= 1000000007;
  }
  void pull(long long pos) { seg[pos] = merge(seg[2 * pos], seg[2 * pos + 1]); }
  void push(long long pos) {}
  void build(long long cur, long long st, long long en) {
    if (st == en) {
      seg[cur] = node(a[st]);
      return;
    }
    long long mid = (st + en) >> 1;
    build(2 * cur, st, mid);
    build(2 * cur + 1, mid + 1, en);
    pull(cur);
  }
  SegTree(long long n_val, vector<long long> &arr) {
    n = n_val;
    seg.resize(4 * n + 5, 0);
    lazy.resize(4 * n + 5, 0);
    a = arr;
    build(1, 1, n);
  }
  void add(long long cur, long long st, long long en, long long ql,
           long long qr, pair<long long, long long> val) {
    if (en < ql or qr < st)
      return;
    else if (ql <= st and en <= qr) {
      apply(cur, val);
      return;
    } else {
      push(cur);
      long long mid = (st + en) >> 1;
      add(2 * cur, st, mid, ql, qr, val);
      add(2 * cur + 1, mid + 1, en, ql, qr, val);
      pull(cur);
    }
  }
  void update(long long pos, pair<long long, long long> val) {
    add(1, 1, n, pos, pos, val);
  }
  void update(long long l, long long r, pair<long long, long long> val) {
    add(1, 1, n, l, r, val);
  }
  node query(long long cur, long long st, long long en, long long ql,
             long long qr) {
    if (en < ql or qr < st)
      return REJECT_NODE;
    else if (ql <= st and en <= qr)
      return seg[cur];
    else {
      push(cur);
      long long mid = (st + en) >> 1;
      node node_l = query(2 * cur, st, mid, ql, qr);
      node node_r = query(2 * cur + 1, mid + 1, en, ql, qr);
      return merge(node_l, node_r);
    }
  }
  pair<long long, long long> get(long long l, long long r) {
    if (l > r) return {0, 0};
    node ans = query(1, 1, n, l, r);
    return {ans.val, ans.ct};
  }
};
void solve() {
  long long n;
  cin >> n;
  unordered_map<long long, long long> id;
  pair<long long, long long> a[n];
  set<long long> k;
  for (long long i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    swap(a[i].first, a[i].second);
    k.insert(a[i].first);
  }
  sort(a, a + n);
  reverse(a, a + n);
  long long mx = (long long)k.size();
  vector<long long> temp(mx + 1, 1000000007), v((k).begin(), (k).end());
  SegTree seg(mx, temp);
  v.insert(v.begin(), -1);
  for (long long i = 0; i < n; i++) {
    long long ub = lower_bound((v).begin(), (v).end(), a[i].second) - v.begin();
    long long idx = lower_bound((v).begin(), (v).end(), a[i].first) - v.begin();
    if (ub == mx + 1) {
      seg.update(idx, {a[i].first, 1});
      continue;
    }
    auto cur = seg.get(ub, mx);
    seg.update(idx, {cur.first + a[i].first - a[i].second, cur.second});
  }
  auto ans = seg.get(1, n);
  cout << ans.second % 1000000007;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
