#include <bits/stdc++.h>
using namespace std;
int b[100005];
int n, x;
int a[100005];
int main() {
  memset(b, 0, sizeof(b));
  scanf("%d", &n);
  int mm;
  int ma = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    b[x]++;
    a[i] = x;
    ma = max(ma, x);
  }
  for (int i = ma; i > 1; i--)
    if (b[i] > b[i - 1]) {
      printf("-1\n");
      return 0;
    }
  printf("%d\n", b[1]);
  for (int i = 1; i <= n; i++) printf("%d ", b[a[i]]--);
  printf("\n");
}
