#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 3;
int n, t[MAXN];
pair<int, int> p[MAXN];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first;
    p[i].second = i;
    t[p[i].first]++;
  }
  sort(p, p + n);
  bool is_r = true;
  for (int i = 1; i < p[n - 1].first; i++)
    if (t[i + 1] > t[i]) is_r = false;
  if (is_r) {
    int c = 1, k = 1;
    for (int i = 0; i < n; i++) {
      if (p[i].first == c) {
        p[i].first = k;
        k++;
      } else {
        c++;
        k = 1;
        p[i].first = k;
        k++;
      }
    }
    for (int i = 0; i < n; i++) swap(p[i].first, p[i].second);
    sort(p, p + n);
    cout << t[1] << endl;
    for (int i = 0; i < n; i++) cout << p[i].second << " ";
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
