#include <bits/stdc++.h>
using namespace std;
int dis[100010];
int main() {
  int n, x, k;
  while (cin >> n) {
    bool work = 0;
    memset(dis, -1, sizeof(dis));
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &x, &k);
      if (work) continue;
      if (x <= dis[k])
        continue;
      else if (x == dis[k] + 1)
        dis[k] = x;
      else {
        work = 1;
      }
    }
    if (work)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
