#include <bits/stdc++.h>
using namespace std;
vector<int> val[100005];
int arr[100005];
int cnt[100005];
int main() {
  int inp, ct = 1, mulai = 0, n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> inp;
    arr[i] = inp;
    cnt[inp]++;
    mulai = max(mulai, inp);
  }
  for (int i = mulai; i; --i) {
    int cur = cnt[i];
    for (int j = 1; j <= cur; ++j) {
      for (int k = i; k; --k) {
        cnt[k]--;
        if (cnt[k] < 0) {
          cout << "-1";
          return 0;
        }
        val[k].push_back(ct);
      }
      ct++;
    }
  }
  cout << ct - 1 << "\n";
  for (int i = 1; i <= n; ++i) {
    cout << val[arr[i]].back() << " ";
    val[arr[i]].pop_back();
  }
  return 0;
}
