#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
int freq[MAXN + 5];
int n;
int arr[MAXN + 5];
int which[MAXN + 5];
int main() {
  int c, c2;
  scanf("%d", &n);
  for (c = 0; c < n; c++) {
    scanf("%d", &arr[c]);
    freq[arr[c]]++;
    which[c] = freq[arr[c]];
  }
  for (c = 1; c <= MAXN; c++)
    if (freq[c] < freq[c + 1]) break;
  if (c > MAXN) {
    printf("%d\n", freq[1]);
    for (c = 0; c < n; c++) {
      if (c) printf(" ");
      printf("%d", which[c]);
    }
    printf("\n");
  } else
    printf("-1\n");
  return 0;
}
