#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0, 0, 0, 0, 0};
int dy[] = {0, 0, 1, -1, 0, 0, 0, 0};
const int inf = 10000000;
int main() {
  int n;
  cin >> n;
  int a[n];
  int ma = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ma = max(ma, a[i]);
  }
  vector<int> ind[ma];
  for (int i = 0; i < n; i++) {
    ind[a[i] - 1].push_back(i);
  }
  int ex = 1;
  for (int i = 1; i < ma; i++) {
    if (ind[i].size() > ind[i - 1].size()) {
      ex = 0;
      break;
    }
  }
  if (!ex) {
    cout << "-1" << endl;
    return 0;
  }
  int res[n];
  for (int i = 0; i < ma; i++) {
    vector<int> x = ind[i];
    for (int j = 0; j < x.size(); j++) {
      res[x[j]] = j + 1;
    }
  }
  cout << ind[0].size() << endl;
  for (int i = 0; i < n; i++) {
    cout << res[i] << " ";
  }
  cout << endl;
  return 0;
}
