#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int mas[MAXN];
int res[MAXN];
map<int, set<int> > numbers;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> mas[i];
    numbers[mas[i]].insert(i);
  }
  map<int, set<int> >::iterator it;
  int k = 0;
  while (1) {
    k++;
    int t = 0;
    int isOut = true;
    for (it = numbers.begin(); it != numbers.end(); it++) {
      t++;
      if (!it->second.empty()) {
        if (t != it->first) {
          cout << "-1";
          return 0;
        }
        int current = *(it->second.begin());
        res[current] = k;
        it->second.erase(it->second.begin());
        isOut = false;
      } else {
        break;
      }
    }
    if (isOut) {
      break;
    }
  }
  for (it = numbers.begin(); it != numbers.end(); it++) {
    if (!it->second.empty()) {
      cout << "-1";
      return 0;
    }
  }
  cout << k - 1 << endl;
  for (int i = 0; i < n; i++) {
    cout << res[i] << " ";
  }
  return 0;
}
