#include <bits/stdc++.h>
int num[100010], cnt[100010], s[100010];
int main() {
  int n, ok, len;
  while (scanf("%d", &n) == 1) {
    len = 0;
    memset(num, 0, sizeof num);
    memset(cnt, 0, sizeof cnt);
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &s[i]);
      len = len > s[i] ? len : s[i];
      ++num[s[i]];
    }
    ok = 1;
    for (int i = 1; i < len; ++i)
      if (!num[i] || num[i] < num[i + 1]) {
        ok = 0;
        break;
      }
    if (!ok) {
      printf("-1\n");
      continue;
    }
    printf("%d\n", num[1]);
    for (int i = 1; i < n; ++i) printf("%d ", ++cnt[s[i]]);
    printf("%d\n", cnt[s[n]] + 1);
  }
}
