#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, k;
  cin >> n;
  set<int> sol[100001];
  int last[100001];
  memset(last, -1, sizeof(last));
  for (int i = 0; i < (n); i++) {
    cin >> x >> k;
    if (last[k] < x) {
      if (last[k] + 1 != x) {
        cout << "NO" << endl;
        return 0;
      }
      sol[k].insert(x);
      last[k] = x;
    } else if (!sol[k].count(x)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
