#include <bits/stdc++.h>
using namespace std::chrono;
using namespace std;
template <typename A, typename B>
ostream& operator<<(ostream& cout, pair<A, B> const& p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename num_t>
struct segtree {
  int n, depth;
  vector<num_t> tree, lazy;
  void init(int second, long long* arr) {
    n = second;
    tree = vector<num_t>(4 * second, 0);
    lazy = vector<num_t>(4 * second, 0);
    init(0, 0, n - 1, arr);
  }
  num_t init(int i, int l, int r, long long* arr) {
    if (l == r) return tree[i] = arr[l];
    int mid = (l + r) / 2;
    num_t a = init(2 * i + 1, l, mid, arr),
          b = init(2 * i + 2, mid + 1, r, arr);
    return tree[i] = a.op(b);
  }
  void update(int l, int r, num_t v) { update(0, 0, n - 1, l, r, v); }
  num_t update(int i, int tl, int tr, int ql, int qr, num_t v) {
    eval_lazy(i, tl, tr);
    if (ql <= tl && tr <= qr) {
      lazy[i] = lazy[i].val + v.val;
      eval_lazy(i, tl, tr);
      return tree[i];
    }
    if (tl > tr || tr < ql || qr < tl) return tree[i];
    if (tl == tr) return tree[i];
    int mid = (tl + tr) / 2;
    num_t a = update(2 * i + 1, tl, mid, ql, qr, v),
          b = update(2 * i + 2, mid + 1, tr, ql, qr, v);
    return tree[i] = a.op(b);
  }
  num_t query(int l, int r) { return query(0, 0, n - 1, l, r); }
  num_t query(int i, int tl, int tr, int ql, int qr) {
    eval_lazy(i, tl, tr);
    if (ql <= tl && tr <= qr) return tree[i];
    if (tl > tr || tr < ql || qr < tl) return num_t::null_v;
    int mid = (tl + tr) / 2;
    num_t a = query(2 * i + 1, tl, mid, ql, qr),
          b = query(2 * i + 2, mid + 1, tr, ql, qr);
    return a.op(b);
  }
  void eval_lazy(int i, int l, int r) {
    tree[i] = tree[i].lazy_op(lazy[i], (r - l + 1));
    if (l != r) {
      lazy[i * 2 + 1] = lazy[i].val + lazy[i * 2 + 1].val;
      lazy[i * 2 + 2] = lazy[i].val + lazy[i * 2 + 2].val;
    }
    lazy[i] = num_t();
  }
};
struct min_t {
  long long val;
  static const long long null_v = 9223372036854775807LL;
  min_t() : val(0) {}
  min_t(long long v) : val(v) {}
  min_t op(min_t& other) { return min_t(min(val, other.val)); }
  min_t lazy_op(min_t v, int size) { return min_t(val + v.val); }
};
long long i, j;
const long long mod = 1e9 + 7;
long long n, q, Q, T, m, k, r, x, y, z, g;
pair<long long, long long> v[200001];
pair<long long, long long> dp[200001];
long long a[200001];
long long sufm[200001];
bool ok[200001];
vector<long long> comp;
vector<long long> loc[200001];
vector<long long> sum[200001];
segtree<min_t> st;
int bins(long long o) {
  int l = 0, r = n - 1;
  while (l <= r) {
    int m = (l + r) / 2;
    if (v[m].second > o)
      r = m - 1;
    else
      l = m + 1;
  }
  return r;
}
int bins_c(long long v) {
  int l = 0, r = comp.size() - 1;
  while (l <= r) {
    int m = (l + r) / 2;
    if (comp[m] == v) return m;
    if (comp[m] > v)
      r = m - 1;
    else
      l = m + 1;
  }
  return -1;
}
int bins_loc(long long i, long long o) {
  int l = 0, r = loc[i].size() - 1;
  while (l <= r) {
    int m = (l + r) / 2;
    if (loc[i][m] > o)
      r = m - 1;
    else
      l = m + 1;
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
  sort(v, v + n);
  for (i = 0; i < n; i++) swap(v[i].first, v[i].second);
  memset(a, 0, sizeof(a));
  st.init(n, a);
  for (i = 0; i < n; i++) {
    long long r = bins(v[i].first);
    if (r == -1)
      dp[i].first = v[i].first;
    else
      dp[i].first = v[i].first + st.query(0, r).val;
    st.update(i, i, dp[i].first - v[i].second);
  }
  comp = vector<long long>(n);
  for (i = 0; i < n; i++) comp[i] = dp[i].first - v[i].second;
  sort(comp.begin(), comp.end());
  comp.erase(unique(comp.begin(), comp.end()), comp.end());
  for (i = 0; i < n; i++) {
    int x = bins_c(dp[i].first - v[i].second);
    loc[x].push_back(i);
  }
  sufm[n - 1] = v[n - 1].first;
  for (int i = n - 2; i >= 0; i--) {
    sufm[i] = max(v[i].first, sufm[i + 1]);
  }
  memset(ok, 0, sizeof(ok));
  long long best = 1e9;
  for (i = 0; i < n; i++) {
    if (i == n - 1 || v[i].second > sufm[i + 1]) {
      best = min(best, dp[i].first);
      ok[i] = 1;
    } else {
      ok[i] = 0;
    }
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    long long r = bins(v[i].first);
    long long x, y;
    if (r == -1) {
      dp[i].second = 1;
    } else {
      x = bins_c(st.query(0, r).val);
      long long y = bins_loc(x, r);
      if (y >= sum[x].size() || y == -1)
        dp[i].second = 1;
      else
        dp[i].second = sum[x][y];
    }
    x = bins_c(dp[i].first - v[i].second);
    if (sum[x].size() == 0)
      sum[x].push_back(dp[i].second);
    else
      sum[x].push_back((sum[x][sum[x].size() - 1] + dp[i].second) % mod);
    if (dp[i].first == best && ok[i]) ans += dp[i].second;
  }
  cout << ans % mod << endl;
}
