#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
const int TOO_MUCH = 1e9 + 1;
const long long MOD = 1e9 + 7;
int n;
int in[N], out[N];
int volumesCount;
int volumes[2 * N];
vector<int> toys[2 * N];
int emptiness[2 * N], setsCount[2 * N];
int treeEmptiness[4 * 2 * N], treeSetsCount[4 * 2 * N];
void choose(int& baseEmp, int& baseCnt, int otherEmp, int otherCnt) {
  if (baseEmp > otherEmp) {
    baseEmp = otherEmp;
    baseCnt = otherCnt;
  } else if (baseEmp == otherEmp) {
    baseCnt += otherCnt;
    baseCnt %= MOD;
  }
}
void update(int i) {
  int lc = 2 * i;
  int rc = 2 * i + 1;
  treeEmptiness[i] = treeEmptiness[lc];
  treeSetsCount[i] = treeSetsCount[lc];
  choose(treeEmptiness[i], treeSetsCount[i], treeEmptiness[rc],
         treeSetsCount[rc]);
}
void build(int i, int l, int r) {
  if (l == r) {
    treeEmptiness[i] = TOO_MUCH;
    treeSetsCount[i] = 0;
    return;
  }
  int lc = 2 * i;
  int rc = 2 * i + 1;
  int m = (l + r) / 2;
  build(lc, l, m);
  build(rc, m + 1, r);
  update(i);
}
void modify(int i, int l, int r, int k, int emp, int cnt) {
  if (l == r) {
    treeEmptiness[i] = emp;
    treeSetsCount[i] = cnt;
    return;
  }
  int lc = 2 * i;
  int rc = 2 * i + 1;
  int m = (l + r) / 2;
  if (k <= m) {
    modify(lc, l, m, k, emp, cnt);
  } else {
    modify(rc, m + 1, r, k, emp, cnt);
  }
  update(i);
}
void analyze(int i, int l, int r, int lt, int rt, int& emp, int& cnt) {
  if (l == lt && r == rt) {
    emp = treeEmptiness[i];
    cnt = treeSetsCount[i];
    return;
  }
  int lc = 2 * i;
  int rc = 2 * i + 1;
  int m = (l + r) / 2;
  if (rt <= m) {
    analyze(lc, l, m, lt, rt, emp, cnt);
  } else if (lt > m) {
    analyze(rc, m + 1, r, lt, rt, emp, cnt);
  } else {
    analyze(lc, l, m, lt, m, emp, cnt);
    int otherEmp, otherCnt;
    analyze(rc, m + 1, r, m + 1, rt, otherEmp, otherCnt);
    choose(emp, cnt, otherEmp, otherCnt);
  }
}
void read() {
  cin >> n;
  volumesCount = 1;
  volumes[0] = 0;
  for (int i = 0; i < n; ++i) {
    cin >> out[i] >> in[i];
    volumes[volumesCount++] = in[i];
    volumes[volumesCount++] = out[i];
  }
  sort(volumes, volumes + volumesCount);
  volumesCount = unique(volumes, volumes + volumesCount) - volumes;
  for (int i = 0; i < n; ++i) {
    int volumeId =
        lower_bound(volumes, volumes + volumesCount, out[i]) - volumes;
    toys[volumeId].push_back(i);
  }
}
long long solve() {
  int resultStart;
  emptiness[0] = TOO_MUCH;
  setsCount[0] = 0;
  for (int volumeId = 0; volumeId < volumesCount; ++volumeId) {
    int maxInId = 0;
    for (int toyId : toys[volumeId]) {
      int innerVolumeId =
          lower_bound(volumes, volumes + volumesCount, in[toyId]) - volumes;
      maxInId = max(maxInId, innerVolumeId);
    }
    if (volumeId == volumesCount - 1) {
      resultStart = maxInId + 1;
    }
    if (maxInId + 1 > volumeId - 1) {
      emptiness[volumeId] = TOO_MUCH;
      setsCount[volumeId] = 0;
    } else {
      analyze(1, 0, volumesCount - 1, maxInId + 1, volumeId - 1,
              emptiness[volumeId], setsCount[volumeId]);
      emptiness[volumeId] -= (volumes[volumesCount - 1] - volumes[volumeId]);
    }
    int strictEmp = TOO_MUCH;
    int strictCnt = 0;
    for (int toyId : toys[volumeId]) {
      int innerVolumeId =
          lower_bound(volumes, volumes + volumesCount, in[toyId]) - volumes;
      int otherEmptiness = emptiness[innerVolumeId];
      int otherCount = setsCount[innerVolumeId];
      if (otherEmptiness >= TOO_MUCH) {
        otherEmptiness = in[toyId];
        otherCount = 1;
      }
      choose(emptiness[volumeId], setsCount[volumeId], otherEmptiness,
             otherCount);
      choose(strictEmp, strictCnt, otherEmptiness, otherCount);
    }
    strictEmp += (volumes[volumesCount - 1] - volumes[volumeId]);
    modify(1, 0, volumesCount - 1, volumeId, strictEmp, strictCnt);
  }
  int totalEmp = TOO_MUCH, totalCnt = 0;
  for (int volumeId = resultStart; volumeId < volumesCount; ++volumeId) {
    int otherEmp = TOO_MUCH, otherCnt = 0;
    analyze(1, 0, volumesCount - 1, volumeId, volumeId, otherEmp, otherCnt);
    otherEmp -= (volumes[volumesCount - 1] - volumes[volumeId]);
    choose(totalEmp, totalCnt, otherEmp, otherCnt);
  }
  return totalCnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  read();
  cout << solve();
  return 0;
}
