#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
void calc(vector<int>& v, vector<int>& xs) {
  vector<int> tab[N];
  int id = 1;
  int maxval = *max_element(v.begin(), v.end());
  for (int i = maxval; i > 0; i--) {
    if (xs[i] == 0) continue;
    int n = xs[i];
    for (int j = i; j > 0; j--) {
      if (xs[j] < n) {
        puts("-1");
        return;
      }
      for (int k = 0; k < n; k++) tab[j].push_back(id + k);
      xs[j] -= n;
    }
    id += n;
  }
  printf("%d\n", id - 1);
  for (int i = 0; i < (int)(v.size()); i++) {
    assert(!tab[v[i]].empty());
    if (i > 0) putchar(' ');
    printf("%d", tab[v[i]].back());
    tab[v[i]].pop_back();
  }
  puts("");
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v(n), xs(N);
  for (int i = 0; i < (int)(n); i++) {
    scanf("%d", &v[i]);
    xs[v[i]]++;
  }
  calc(v, xs);
}
