#include <bits/stdc++.h>
using namespace std;
int a[100100], used[100100];
int b[100100];
vector<vector<int> > store;
int main() {
  int n, x, maxN = 0;
  cin >> n;
  store.resize(100100);
  for (int i = 0; i < n; i++) {
    cin >> x;
    a[x]++;
    store[x].push_back(i);
    maxN = max(maxN, x);
  }
  a[0] = a[1];
  for (int i = 1; i <= maxN; i++) {
    if (a[i] > a[i - 1]) {
      cout << -1;
      return 0;
    }
  }
  int cur = 0;
  while (a[1]) {
    int index = 1;
    ++cur;
    while (a[index]) {
      a[index]--;
      b[store[index][used[index]]] = cur;
      used[index]++;
      index++;
    }
  }
  cout << cur << endl;
  for (int i = 0; i < n; i++) cout << b[i] << " ";
  return 0;
}
