#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int MAXD = MAXN * 2;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
inline void add_mod(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
struct Segment_Tree {
  pair<int, int> tree[MAXD << 2];
  inline void upd(pair<int, int> &p, const pair<int, int> &q) {
    if (p.first == q.first)
      add_mod(p.second, q.second);
    else if (p.first > q.first)
      p = q;
  }
  inline void push_up(int u) {
    if (tree[((u) << 1)].first != tree[((u) << 1 | 1)].first)
      tree[u] = min(tree[((u) << 1)], tree[((u) << 1 | 1)]);
    else
      tree[u] = make_pair(
          tree[((u) << 1)].first,
          (tree[((u) << 1)].second + tree[((u) << 1 | 1)].second) % mod);
  }
  void build(int u, int l, int r) {
    tree[u] = make_pair(inf, 0);
    if (l == r) return;
    int mid = (l + r) >> 1;
    build(((u) << 1), l, mid);
    build(((u) << 1 | 1), mid + 1, r);
  }
  void update(int u, int l, int r, int q, pair<int, int> k) {
    if (l == r) {
      upd(tree[u], k);
      return;
    }
    int mid = (l + r) >> 1;
    if (q <= mid)
      update(((u) << 1), l, mid, q, k);
    else
      update(((u) << 1 | 1), mid + 1, r, q, k);
    push_up(u);
  }
  pair<int, int> query(int u, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return tree[u];
    int mid = (l + r) >> 1;
    pair<int, int> res(inf, 0);
    if (ql <= mid) upd(res, query(((u) << 1), l, mid, ql, qr));
    if (mid < qr) upd(res, query(((u) << 1 | 1), mid + 1, r, ql, qr));
    return res;
  }
};
pair<int, int> p[MAXN];
int f[MAXN], g[MAXN];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &p[i].first, &p[i].second);
  sort(p + 1, p + n + 1);
  static int dsc[MAXD], dcnt = 0;
  dsc[++dcnt] = 0;
  for (int i = 1; i <= n; ++i)
    dsc[++dcnt] = p[i].first, dsc[++dcnt] = p[i].second;
  sort(dsc + 1, dsc + dcnt + 1);
  dcnt = unique(dsc + 1, dsc + dcnt + 1) - dsc - 1;
  for (int i = 1; i <= n; ++i)
    p[i].first = lower_bound(dsc + 1, dsc + dcnt + 1, p[i].first) - dsc,
    p[i].second = lower_bound(dsc + 1, dsc + dcnt + 1, p[i].second) - dsc;
  int mxl = 0;
  for (int i = 1; i <= n; ++i) mxl = max(mxl, p[i].second);
  static Segment_Tree tree;
  tree.build(1, 1, dcnt);
  tree.update(1, 1, dcnt, 1, make_pair(0, 1));
  pair<int, int> ans = make_pair(inf, 0);
  for (int i = 1; i <= n; ++i) {
    int l = p[i].second, r = p[i].first;
    pair<int, int> res = tree.query(1, 1, dcnt, 1, l);
    f[i] = res.first + dsc[l];
    g[i] = res.second;
    tree.update(1, 1, dcnt, r, make_pair(f[i] - dsc[r], g[i]));
    if (r > mxl) tree.upd(ans, make_pair(f[i], g[i]));
  }
  printf("%d\n", ans.second);
  return 0;
}
