#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  int id, val, num;
} a[100005];
bool cmp(node u, node v) {
  return u.id < v.id || (u.id == v.id && u.num < v.num);
}
int main() {
  scanf("%d", &n);
  bool ans = true;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].val, &a[i].id);
    a[i].num = i;
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    int j = i;
    while (j + 1 <= n && a[j + 1].id == a[j].id) j++;
    int tmp = -1;
    for (int k = i; k <= j; k++) {
      if (a[k].val > tmp) {
        if (a[k].val == tmp + 1)
          tmp = a[k].val;
        else
          ans = false;
      }
    }
    i = j;
  }
  if (ans)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
