#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const double eps = 1e-9;
struct point {
  int x, k, pos;
};
bool cmp(point p1, point p2) {
  if (p1.k < p2.k || (p1.k == p2.k && p1.x < p2.x) ||
      (p1.k == p2.k && p1.x == p2.x && p1.pos < p2.pos))
    return true;
  return false;
}
int n;
point a[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].x >> a[i].k;
    a[i].pos = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; ++i) {
    if (a[i].k == a[i - 1].k) {
      if (a[i].x == a[i - 1].x) {
        a[i].pos = a[i - 1].pos;
      } else if (a[i].pos < a[i - 1].pos) {
        cout << "NO\n";
        return 0;
      } else if (a[i].x != a[i - 1].x + 1) {
        cout << "NO\n";
        return 0;
      }
    } else {
      if (a[i].x != 0) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
