#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 1000;
int arr[MAXN];
vector<int> pt[MAXN];
int mrk[MAXN];
int32_t main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++) pt[arr[i]].push_back(i);
  int cnt = n;
  int cnt_2 = 1;
  while (cnt) {
    if (pt[1].size() == 0) {
      cout << -1 << endl;
      return 0;
    }
    int pt_2 = 1;
    while (pt[pt_2].size() > 0) {
      mrk[pt[pt_2][pt[pt_2].size() - 1]] = cnt_2;
      pt[pt_2].pop_back();
      cnt--;
      pt_2++;
    }
    cnt_2++;
  }
  cout << *max_element(mrk, mrk + n) << endl;
  for (int i = 0; i < n; i++) cout << mrk[i] << ' ';
  cout << endl;
}
