#include <bits/stdc++.h>
int n;
int a[100005], b[100005], c[100005];
int res[100005];
bool check() {
  c[0] = 0x3f3f3f3f;
  for (int i = 0; i < n; i++) {
    if (a[i] > n || c[i] < c[i + 1]) {
      return false;
    }
  }
  return true;
}
int main() {
  memset(b, 0, sizeof(b));
  memset(c, 0, sizeof(c));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    c[a[i]]++;
  }
  if (!check()) {
    puts("-1");
    return 0;
  }
  printf("%d\n", c[1]);
  for (int i = 0; i < n; i++) {
    res[i] = ++b[a[i]];
    printf("%d%c", res[i], i + 1 == n ? '\n' : ' ');
  }
  return 0;
}
