#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const int maxn = 200010;
int n;
pair<int, int> dolls[maxn];
struct Node {
  Node *l, *r;
  int tl, tr, tm;
  long long minval, ways;
  Node() {}
  Node(int treel, int treer) { init(treel, treer); }
  void init(int treel, int treer) {
    tl = treel;
    tr = treer;
    build();
  }
  void merge() {
    if (l->minval < r->minval) {
      minval = l->minval;
      ways = l->ways;
    } else if (l->minval > r->minval) {
      minval = r->minval;
      ways = r->ways;
    } else {
      minval = l->minval;
      ways = (l->ways + r->ways) % mod;
    }
  }
  void build() {
    if (tl == tr) {
      minval = inf;
      ways = 0;
    } else {
      tm = (tl + tr) / 2;
      l = new Node(tl, tm);
      r = new Node(tm + 1, tr);
      merge();
    }
  }
  void update(int pos, long long val, long long ways) {
    if (tl == tr) {
      this->minval = val;
      this->ways = ways;
    } else {
      if (pos <= tm) {
        l->update(pos, val, ways);
      } else {
        r->update(pos, val, ways);
      }
      merge();
    }
  }
  pair<long long, long long> query(int i) {
    if (dolls[tr].first < dolls[i].second)
      return pair<long long, long long>(inf, 0);
    if (dolls[i].second <= dolls[tl].first)
      return pair<long long, long long>(minval, ways);
    pair<long long, long long> res1 = l->query(i);
    pair<long long, long long> res2 = r->query(i);
    if (res1.first < res2.first) {
      return res1;
    } else if (res2.first < res1.first) {
      return res2;
    } else {
      return pair<long long, long long>(res1.first,
                                        (res1.second + res2.second) % mod);
    }
  }
} tree;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> dolls[i].second >> dolls[i].first;
  }
  sort(dolls, dolls + n, [&](pair<int, int>& a, pair<int, int>& b) {
    return a.first != b.first ? a.first < b.first : a.second < b.second;
  });
  tree.init(0, n - 1);
  for (int i = n - 1; i >= 0; --i) {
    pair<long long, long long> res = tree.query(i);
    if (res.first == inf) {
      long long val = dolls[i].first;
      tree.update(i, val, 1);
    } else {
      long long val = dolls[i].first - dolls[i].second + res.first;
      tree.update(i, val, res.second);
    }
  }
  cout << tree.ways << '\n';
}
