#include <bits/stdc++.h>
using namespace std;
struct info {
  int n;
  int pos;
  int ind;
} val[100005];
int N, ans;
int c[100005];
bool cmp(struct info a, struct info b) { return a.n < b.n; }
bool cmp1(struct info a, struct info b) { return a.ind < b.ind; }
int main() {
  int i;
  scanf("%d", &N);
  ans = 0;
  for (i = 0; i < N; i++) {
    scanf("%d", &val[i].n);
    if (val[i].n == 1) ans++;
    val[i].ind = i;
  }
  bool flag = true;
  sort(val, val + N, cmp);
  for (i = 0; i < N; i++) {
    if (val[i].n == 1) {
      val[i].pos = c[val[i].n] + 1;
      c[1]++;
    } else {
      if (c[val[i].n] >= ans) flag = false;
      val[i].pos = (c[val[i].n]) + 1;
      c[val[i].n]++;
      if (c[val[i].n - 1] < c[val[i].n]) flag = false;
    }
  }
  sort(val, val + N, cmp1);
  if (!flag) {
    printf("%d\n", -1);
    return 0;
  }
  printf("%d\n", ans);
  for (int k = 0; k < N; k++) {
    if (k) printf(" ");
    printf("%d", val[k].pos);
  }
  printf("\n");
  return 0;
}
