#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> *v = new vector<int>();
  int n, a;
  cin >> n;
  int arr[n], res[n];
  for (int i = 0; i < n; i++) {
    cin >> a;
    arr[i] = a;
    if (a > v->size()) {
      v->resize(a);
    }
    v->at(a - 1)++;
  }
  int nv = v->at(0);
  for (int i = 1; i < v->size(); i++) {
    if (v->at(i) > v->at(i - 1) || v->at(i) == 0) {
      cout << -1;
      return 0;
    }
  }
  cout << v->at(0) << "\n";
  for (int i = 0; i < n; i++) {
    res[i] = (v->at(arr[i] - 1))--;
  }
  for (int i = 0; i < n; i++) {
    cout << res[i] << "\n";
  }
  return 0;
}
