#include <bits/stdc++.h>
int xx[100000], kk[100000];
int compare(const void *a, const void *b) {
  int i = *(int *)a;
  int j = *(int *)b;
  return kk[i] != kk[j] ? kk[i] - kk[j] : i - j;
}
int main() {
  static int ii[100000];
  static char used[100000 + 1];
  int n, i, j, k, a;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &xx[i], &kk[i]);
    ii[i] = i;
  }
  qsort(ii, n, sizeof *ii, compare);
  for (i = 0; i < n;) {
    j = i + 1;
    while (j < n && kk[ii[j]] == kk[ii[i]]) j++;
    a = 0;
    for (k = i; k < j; k++)
      if (!used[xx[ii[k]]]) {
        if (xx[ii[k]] != a) {
          printf("NO\n");
          return 0;
        }
        a++;
        used[xx[ii[k]]] = 1;
      }
    i = j;
    memset(used, 0, sizeof used);
  }
  printf("YES\n");
  return 0;
}
