#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
long long int n, per[200010];
vector<pair<long long int, long long int> > outer_layer;
pair<long long int, long long int> maxa(pair<long long int, long long int> a,
                                        pair<long long int, long long int> b) {
  if (a.first > b.first)
    return a;
  else
    return b;
}
pair<long long int, long long int> mina(pair<long long int, long long int> a,
                                        pair<long long int, long long int> b) {
  if (a.first < b.first)
    return a;
  else
    return b;
}
bool sort_by(long long int i, long long int j) {
  return outer_layer[i].second < outer_layer[j].second;
}
pair<long long int, long long int> solid_area[200010];
pair<long long int, long long int> combine(
    pair<long long int, long long int> a,
    pair<long long int, long long int> b) {
  if (a.first == b.first) {
    return {a.first, (a.second + b.second) % 1000000007};
  }
  return maxa(a, b);
}
pair<long long int, long long int> Se[200010 << 2];
void build(long long int id = 1, long long int l = 0, long long int r = n) {
  if (r - l < 2) {
    Se[id] = solid_area[l];
    return;
  }
  long long int mid = (l + r) >> 1;
  build(2 * id, l, mid);
  build(2 * id + 1, mid, r);
  Se[id] = combine(Se[2 * id], Se[2 * id + 1]);
}
void update(long long int p, pair<long long int, long long int> value,
            long long int id = 1, long long int l = 0, long long int r = n) {
  if (r - l < 2) {
    Se[id] = value;
    return;
  }
  long long int mid = (l + r) >> 1;
  if (p < mid)
    update(p, value, 2 * id, l, mid);
  else
    update(p, value, 2 * id + 1, mid, r);
  Se[id] = combine(Se[2 * id], Se[2 * id + 1]);
}
pair<long long int, long long int> maximum(long long int x, long long int y,
                                           long long int id = 1,
                                           long long int l = 0,
                                           long long int r = n) {
  if (x >= r || y <= l) return {0, 0};
  if (x <= l && r <= y) return Se[id];
  long long int mid = (l + r) >> 1;
  return combine(maximum(x, y, 2 * id, l, mid),
                 maximum(x, y, 2 * id + 1, mid, r));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  clock_t clk = clock();
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    outer_layer.push_back({a, b});
  }
  for (int i = 0; i < n; i++) per[i] = i;
  sort(outer_layer.begin(), outer_layer.end());
  sort(per, per + n, sort_by);
  for (int i = 0; i < n; i++)
    solid_area[i] = {outer_layer[i].first - outer_layer[i].second, 1};
  build();
  for (int i = 0; i < n; i++) {
    long long int j = per[i];
    pair<long long int, long long int> ser = {outer_layer[j].second, 1e17};
    long long int idx =
        (int)(std::upper_bound(outer_layer.begin(), outer_layer.end(), ser) -
              outer_layer.begin());
    pair<long long int, long long int> min_data = maximum(0, idx);
    min_data = {min_data.first + outer_layer[j].first - outer_layer[j].second,
                min_data.second};
    solid_area[j] = combine(solid_area[j], min_data);
    update(j, solid_area[j]);
  }
  pair<long long int, long long int> ans = {1e17, 0};
  vector<long long int> internal_data;
  for (int i = 0; i < n; i++) {
    internal_data.push_back(outer_layer[i].second);
  }
  sort(internal_data.begin(), internal_data.end());
  for (int i = 0; i < n; i++) {
    pair<long long int, long long int> blank_space = {
        outer_layer[i].first - solid_area[i].first, solid_area[i].second};
    long long int out = outer_layer[i].first;
    long long int idx =
        (int)(lower_bound(internal_data.begin(), internal_data.end(), out) -
              internal_data.begin());
    if (idx != n) continue;
    if (ans.first == blank_space.first) {
      ans.second = (ans.second + blank_space.second) % 1000000007;
    } else
      ans = mina(ans, blank_space);
  }
  cout << ans.second << endl;
  cerr << endl
       << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
  return 0;
}
