#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template <class T>
inline bool ckmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
inline bool ckmax(T &a, T b) {
  return b > a ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const char nl = '\n';
const int mxN = 2e5 + 10;
const int MOD = 1e9 + 7;
const long long infLL = 1e18;
int fact[mxN];
int add(int x, int y) {
  x += y;
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
  return x;
}
void ad(int &x, int y) { x = add(x, y); }
int sub(int x, int y) {
  x -= y;
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
  return x;
}
void sb(int &x, int y) { x = sub(x, y); }
int mul(int x, int y) { return ((int64_t)x * (int64_t)y) % MOD; }
void ml(int &x, int y) { x = mul(x, y); }
int binpow(int x, int y) {
  int z = 1;
  while (y > 0) {
    if (y % 2 == 1) z = mul(z, x);
    x = mul(x, x);
    y /= 2;
  }
  return z;
}
int inv(int x) { return binpow(x, MOD - 2); }
int divide(int x, int y) { return mul(x, inv(y)); }
void precalc() {
  fact[0] = 1;
  for (int i = 1; i < mxN; i++) fact[i] = mul(i, fact[i - 1]);
}
int choose(int n, int k) {
  if (k > n) return 0;
  return divide(fact[n], mul(fact[n - k], fact[k]));
}
using node = pii;
struct segtree {
  int size;
  vector<node> vals;
  node ne = {MOD, 0};
  node comb(node a, node b) {
    if (a.first < b.first)
      return a;
    else if (a.first > b.first)
      return b;
    else
      return {a.first, add(a.second, b.second)};
  }
  void init(int n) {
    size = 1;
    while (size < n) {
      size *= 2;
    }
    vals.assign(2 * size, ne);
  }
  void build(vector<node> &a, int x, int lx, int rx) {
    if (rx - lx == 1) {
      if (lx < (int)a.size()) {
        vals[x] = a[lx];
      }
      return;
    }
    int m = (lx + rx) / 2;
    build(a, 2 * x + 1, lx, m);
    build(a, 2 * x + 2, m, rx);
    vals[x] = comb(vals[2 * x + 1], vals[2 * x + 2]);
  }
  void build(vector<node> &a) { build(a, 0, 0, size); }
  void update(int i, node v, int x, int lx, int rx) {
    if (rx - lx == 1) {
      vals[x] = v;
      return;
    }
    int m = (lx + rx) / 2;
    if (i < m)
      update(i, v, 2 * x + 1, lx, m);
    else
      update(i, v, 2 * x + 2, m, rx);
    vals[x] = comb(vals[2 * x + 1], vals[2 * x + 2]);
  }
  void update(int i, node v) { update(i, v, 0, 0, size); }
  node query(int l, int r, int x, int lx, int rx) {
    if (lx >= r || l >= rx) return ne;
    if (lx >= l && rx <= r) {
      return vals[x];
    }
    int m = (lx + rx) / 2;
    node s1 = query(l, r, 2 * x + 1, lx, m);
    node s2 = query(l, r, 2 * x + 2, m, rx);
    return comb(s1, s2);
  }
  node query(int l, int r) { return query(l, r, 0, 0, size); }
} st;
int n;
vpii a;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  a.resize(n);
  for (int i = (0); i < (n); i++) cin >> a[i].second >> a[i].first;
  sort(a.begin(), a.end());
  st.init(n);
  for (int i = (n - 1); i >= (0); i--) {
    int j = lower_bound(a.begin(), a.end(), (pii){a[i].second, 0}) - a.begin();
    if (j == n) {
      st.update(i, {a[i].first, 1});
    } else {
      pii most = st.query(j, n);
      st.update(i, {most.first - (a[i].second - a[i].first), most.second});
    }
  }
  cout << st.query(0, n).second << nl;
  return 0;
}
