#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const int MAX = 2e5;
const long long oo = 1e15;
vector<pair<long long, long long>> vec;
long long n;
pair<long long, long long> t[4 * MAX], d[MAX];
pair<long long, long long> combine(pair<long long, long long> p1,
                                   pair<long long, long long> p2) {
  pair<long long, long long> res;
  res.first = min(p1.first, p2.first);
  if (p1.first == p2.first) {
    res.second = p1.second + p2.second;
  } else if (p1.first < p2.first) {
    res.second = p1.second;
  } else {
    res.second = p2.second;
  }
  res.second %= M;
  return res;
}
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = make_pair(0, 0);
    return;
  }
  int tm = (tl + tr) / 2;
  build(2 * v, tl, tm);
  build(2 * v + 1, tm + 1, tr);
  t[v] = combine(t[2 * v], t[2 * v + 1]);
}
pair<long long, long long> get(int v, int tl, int tr, int l, int r) {
  if (tl == l && tr == r) {
    return t[v];
  }
  int tm = (tl + tr) / 2;
  if (r <= tm) {
    return get(2 * v, tl, tm, l, r);
  } else if (l >= tm + 1) {
    return get(2 * v + 1, tm + 1, tr, l, r);
  } else {
    pair<long long, long long> p1 = get(2 * v, tl, tm, l, tm);
    pair<long long, long long> p2 = get(2 * v + 1, tm + 1, tr, tm + 1, r);
    return combine(p1, p2);
  }
}
void upd(int v, int tl, int tr, int pos, long long x) {
  if (tl == tr) {
    t[v].first = d[tl].first;
    t[v].second = d[tl].second;
    return;
  }
  int tm = (tl + tr) / 2;
  if (pos <= tm) {
    upd(2 * v, tl, tm, pos, x);
  } else {
    upd(2 * v + 1, tm + 1, tr, pos, x);
  }
  t[v] = combine(t[2 * v], t[2 * v + 1]);
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    long long out, in;
    cin >> out >> in;
    vec.push_back(make_pair(in, out));
  }
  sort(vec.begin(), vec.end());
  long long mn = 1e15;
  long long ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    int l = i, r = n;
    while (r - l > 1) {
      int m = l + (r - l) / 2;
      if (vec[m].first >= vec[i].second) {
        r = m;
      } else {
        l = m;
      }
    }
    pair<long long, long long> t = make_pair(-1, -1);
    if (r == n) {
      d[i].first = vec[i].first;
      d[i].second = 1;
      upd(1, 0, n - 1, i, vec[i].first);
    } else {
      t = get(1, 0, n - 1, r, n - 1);
      d[i].first = t.first - (vec[i].second - vec[i].first);
      d[i].second = t.second;
      upd(1, 0, n - 1, i, t.first - (vec[i].second - vec[i].first));
    }
    if (mn > d[i].first) {
      ans = d[i].second;
      mn = d[i].first;
    } else if (mn == d[i].first) {
      ans += d[i].second;
      ans %= M;
    }
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
