#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
long long segsum[8 * (N + 1)];
int dpsum[8 * (N + 1)];
void update(int node, int start, int end, int idx, long long sum, int dp) {
  if (start > end || idx < start || end < idx) return;
  if (start == end) {
    if (segsum[node] == sum) {
      dpsum[node] += dp;
      dpsum[node] %= mod;
    } else if (segsum[node] > sum) {
      dpsum[node] = dp;
      segsum[node] = sum;
    }
    return;
  }
  int mid = (start + end) >> 1;
  update(node << 1, start, mid, idx, sum, dp);
  update(node << 1 | 1, mid + 1, end, idx, sum, dp);
  segsum[node] = min(segsum[node << 1], segsum[node << 1 | 1]);
  dpsum[node] = 0;
  if (segsum[node] == segsum[node << 1]) {
    dpsum[node] += dpsum[node << 1];
    dpsum[node] %= mod;
  }
  if (segsum[node] == segsum[node << 1 | 1]) {
    dpsum[node] += dpsum[node << 1 | 1];
    dpsum[node] %= mod;
  }
}
pair<long long, int> query(int node, int start, int end, int l, int r) {
  if (start > end || r < start || end < l) return {1e18, 0};
  if (l <= start && end <= r) {
    return {segsum[node], dpsum[node]};
  }
  int mid = (start + end) >> 1;
  auto q1 = query(node << 1, start, mid, l, r);
  auto q2 = query(node << 1 | 1, mid + 1, end, l, r);
  long long sum = min(q1.first, q2.first);
  int dps = 0;
  if (sum == q1.first) {
    dps += q1.second;
    dps %= mod;
  }
  if (sum == q2.first) {
    dps += q2.second;
    dps %= mod;
  }
  return {sum, dps};
}
int main() {
  int n, test = 1, a, b;
  while (test--) {
    vector<pair<int, int> > v;
    map<int, int> my;
    scanf("%d", &n);
    for (int i = 0; i <= 8 * n; i++) {
      segsum[i] = 1e18;
      dpsum[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d %d", &a, &b);
      my[b] = 1;
      my[a] = 1;
      v.push_back({a, b});
    }
    int cnt = 0;
    for (auto it = my.begin(); it != my.end(); it++) {
      it->second = ++cnt;
    }
    sort(v.begin(), v.end());
    for (int i = v.size() - 1; i >= 0; i--) {
      int out = v[i].first, in = v[i].second;
      int pos = my[out];
      auto it = query(1, 1, cnt, pos, cnt);
      int dps = it.second;
      long long sum = it.first;
      if (sum == 1e18) {
        dps = 1;
        sum = in;
      } else {
        sum += in - out;
      }
      update(1, 1, cnt, my[in], sum, dps);
    }
    printf("%d\n", query(1, 1, cnt, 1, cnt).second);
  }
  return 0;
}
