#include <bits/stdc++.h>
using namespace std;
int main() {
  int num[100010], n, counter[100010], ans[100010], i;
  scanf("%d", &n);
  for (i = 0; i <= 100000; ++i) {
    counter[i] = 0;
    ans[i] = 0;
  }
  for (i = 0; i < n; ++i) {
    scanf("%d", &num[i]);
    ++counter[num[i]];
  }
  bool status = true;
  for (i = 2; i <= 100000; ++i) {
    if (counter[i] > counter[i - 1]) status = false;
  }
  if (!status)
    printf("-1\n");
  else {
    printf("%d\n", counter[1]);
    for (i = 0; i < n; ++i) printf("%d ", ++ans[num[i]]);
    printf("\n");
  }
  return 0;
}
