#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int maxv = 0;
  vector<int> t(n), c(100000);
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
    ++c[t[i] - 1];
    if (maxv < t[i]) maxv = t[i];
  }
  int maxnum = *max_element(c.begin(), c.begin() + maxv);
  bool f = true;
  int temp = c[0];
  for (int i = 0; i < maxv; ++i) {
    if (c[i] > temp) {
      f = false;
      break;
    }
    temp = c[i];
  }
  if (f) {
    cout << c[0] << endl;
    vector<int> cc(maxv);
    for (int i = 0; i < n; ++i) {
      cout << ++cc[t[i] - 1] << ' ';
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
