#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n;
pair<int, int> a[1001000];
struct node {
  node *l, *r;
  pair<long long, long long> val;
  bool take;
  node() {
    l = r = NULL;
    val = {1e9, 0};
    take = 0;
  }
};
node* root;
pair<long long, long long> chos(pair<int, int> x, pair<int, int> y) {
  if (x.first < y.first) return x;
  if (y.first < x.first) return y;
  return {x.first, (x.second + y.second) % mod};
}
void up(node*& it) {
  if (it->l) it->l->take |= it->take;
  if (it->r) it->r->take |= it->take;
}
void add(node*& it, int in, pair<long long, long long> x, int l = 1,
         int h = 1e9 + 2) {
  if (!it) it = new node();
  if (l == h) {
    it->val = chos(it->val, x);
    return;
  }
  up(it);
  int m = (l + h) / 2;
  if (in <= m) {
    add(it->l, in, x, l, m);
  } else {
    add(it->r, in, x, m + 1, h);
  }
  if (it->l && it->r)
    it->val = chos(it->l->val, it->r->val);
  else if (it->l)
    it->val = it->l->val;
  else if (it->r)
    it->val = it->r->val;
}
pair<long long, long long> cal(node*& it, int a, int b, int l = 1,
                               int h = 1e9 + 2) {
  if (!it) return {0, 0};
  if (l == a && b == h) {
    it->take = 1;
    return it->val;
  }
  up(it);
  int m = (l + h) / 2;
  if (b <= m) {
    return cal(it->l, a, b, l, m);
  } else if (a > m) {
    return cal(it->r, a, b, m + 1, h);
  } else {
    return chos(cal(it->l, a, m, l, m), cal(it->r, m + 1, b, m + 1, h));
  }
}
int getMn(node*& it, int l = 1, int h = 1e9 + 2) {
  if (!it) return 1e9;
  if (l == h) {
    if (it->take) return 1e9;
    return it->val.first + l;
  }
  up(it);
  int m = (l + h) / 2;
  return min(getMn(it->l, l, m), getMn(it->r, m + 1, h));
}
long long co(node*& it, int x, int l = 1, int h = 1e9 + 2) {
  if (!it) return 0;
  if (l == h) {
    if (it->take) return 0;
    if (it->val.first + l == x) return it->val.second;
    return 0;
  }
  up(it);
  int m = (l + h) / 2;
  return (co(it->l, x, l, m) + co(it->r, x, m + 1, h)) % mod;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i].second, &a[i].first);
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    pair<int, int> z = cal(root, 1, a[i].first);
    z.first += a[i].first - a[i].second;
    add(root, a[i].second, z);
    add(root, a[i].second, {a[i].first - a[i].second, 1});
    pair<int, int> z1 = cal(root, 1, a[i].first);
  }
  int mn = getMn(root);
  cout << co(root, mn) << endl;
  return 0;
}
