#include <bits/stdc++.h>
using namespace std;
struct S {
  int id, num, group;
  S() {}
  bool operator<(const S &rhs) const { return num < rhs.num; }
};
int main() {
  int n, tmp[100000], pre, ng;
  while (scanf("%d", &n) + 1) {
    S s[100000];
    for (int i = 0; i < (int)(n); i++) {
      scanf("%d", &s[i].num);
      s[i].id = i;
    }
    sort(s, s + n);
    if (s[0].num > 1) {
      puts("-1");
      goto NEXT;
    }
    pre = 1 << 28;
    for (int i = 1, j = 0; j < n; i++) {
      int k = j;
      while (j < n && s[j].num == i) {
        s[j].group = j - k + 1;
        j++;
      }
      if (i == 1) ng = j - k;
      if (j - k > pre) {
        puts("-1");
        goto NEXT;
      }
      pre = j - k;
    }
    for (int i = 0; i < (int)(n); i++) tmp[s[i].id] = s[i].group;
    printf("%d\n", ng);
    for (int i = 0; i < (int)(n); i++) printf("%d ", tmp[i]);
    puts("");
  NEXT:;
  }
  return 0;
}
