#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;
int in, out, p, ans, dp[N], mn[N];
void add(int &a, int b) {
  a += mod, b += mod, a %= mod, b %= mod;
  a = (a + b) % mod;
}
vector<pair<int, int> > v;
map<long long, int> mp;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > temp;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &out, &in);
    v.push_back({in, out});
  }
  sort(v.begin(), v.end());
  int min_out = 2e9, Min = 2e9;
  for (int i = 0; i < v.size(); i++) {
    temp.push_back({v[i].second, i});
    if (v[i].first < min_out) dp[i] = 1, mn[i] = v[i].first;
    min_out = min(min_out, v[i].second);
  }
  sort(temp.begin(), temp.end());
  for (int i = 0; i < v.size(); i++) {
    while (p < v.size()) {
      int pp = temp[p].second;
      if (v[pp].second <= v[i].first) {
        add(mp[mn[pp] - v[pp].second], dp[pp]), p++;
      } else
        break;
    }
    if (!mp.empty())
      add(dp[i], mp.begin()->second), mn[i] = mp.begin()->first + v[i].first;
    if (v[i].second > v.back().first) Min = min(Min, mn[i]);
  }
  for (int i = 0; i < v.size(); i++) {
    if (mn[i] == Min && v[i].second > v.back().first) add(ans, dp[i]);
  }
  printf("%d", max(1, ans));
  return 0;
}
