#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int b[maxn];
struct st {
  int k, idx;
  st() {}
  st(int k1, int idx1) {
    k = k1;
    idx = idx1;
  }
} a[maxn];
bool cmp1(const st &a, const st &b) { return a.k < b.k; }
vector<st> v[maxn];
int main() {
  int n, i, j, x, d = 1;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    a[i] = st(x, i);
  }
  sort(a + 1, a + n + 1, cmp1);
  v[1].push_back(a[1]);
  for (i = 2; i <= n; i++) {
    if (a[i].k > a[i - 1].k) d++;
    v[d].push_back(a[i]);
  }
  for (i = 1; i < d; i++)
    if (v[i].size() < v[i + 1].size()) {
      printf("-1\n");
      return 0;
    }
  for (i = 1; i <= d; i++)
    if (v[i][0].k != i) {
      printf("-1\n");
      return 0;
    }
  i = d;
  x = 0;
  while (i > 0) {
    if (v[i].size() == 0) {
      i--;
      continue;
    }
    j = i;
    x++;
    for (; j > 0; j--) b[v[j].back().idx] = x, v[j].pop_back();
  }
  printf("%d\n", x);
  for (i = 1; i <= n; i++) printf("%d ", b[i]);
  printf("\n");
  return 0;
}
