#include <bits/stdc++.h>
using namespace std;
int p[100005], a[100005], g[100005];
int main() {
  int n, i, m, t = 0;
  memset(p, 0, sizeof(p));
  memset(g, 0, sizeof(g));
  scanf("%d", &n);
  m = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", a + i);
    if (m < a[i]) m = a[i];
    p[a[i]]++;
  }
  for (i = 2; i <= m; i++)
    if (p[i] > p[i - 1]) {
      t = 1;
      break;
    }
  if (t)
    printf("-1\n");
  else {
    printf("%d\n", p[1]);
    for (i = 0; i < n - 1; i++) printf("%d ", ++g[a[i]]);
    printf("%d\n", ++g[a[n - 1]]);
  }
  return 0;
}
