#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    f |= (ch == '-');
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x = f ? -x : x;
  return;
}
const int N = 1e5 + 10;
int n, a[N], cs[N], Msum, wz, sc[N], tot;
int main() {
  read(n);
  for (register int i = 1; i <= n; i++) {
    read(a[i]);
    cs[a[i]]++;
    Msum = max(Msum, a[i]);
  }
  for (register int i = Msum; i >= 1; i--) {
    if (cs[i] < cs[i + 1]) {
      cout << -1;
      return 0;
    }
  }
  printf("%d\n", cs[1]);
  for (register int i = 1; i <= n; i++) {
    sc[a[i]]++;
    printf("%d ", sc[a[i]]);
  }
  return 0;
}
