#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<long long> v(n), ans(n);
  vector<vector<long long> > idxs(100100);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    idxs[v[i]].push_back(i);
  }
  long long up = 0;
  for (long long i = 1; i <= 100000; i++) {
    if (idxs[i].size()) up = i;
    if (idxs[i].size() < idxs[i + 1].size()) {
      cout << -1;
      return 0;
    }
  }
  long long cnt = 1;
  while (up) {
    while ((up > 0) && idxs[up].size() == 0) up--;
    if (!up) break;
    for (long long i = 1; i <= up; i++) {
      ans[idxs[i].back()] = cnt;
      idxs[i].pop_back();
    }
    cnt++;
  }
  cout << (cnt - 1) << endl;
  for (long long i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
