#include <bits/stdc++.h>
using namespace std;
int d[int(1e5 + 10)], e[int(1e5 + 10)];
bool solve(int a[], int n) {
  int b[n], c = 1;
  for (int i = 0; i < n; i++) b[i] = a[i];
  sort(b, b + n);
  if (b[0] != 1) return false;
  for (int i = 1; i < n; i++)
    if (b[i] == b[i - 1])
      c++;
    else {
      d[b[i - 1]] = c;
      if (b[i] > b[i - 1] + 1) return false;
      c = 1;
    }
  d[b[n - 1]] = c;
  for (int i = 2; i <= b[n - 1]; i++)
    if (d[i] > d[i - 1]) return false;
  return true;
}
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  if (solve(a, n)) {
    cout << d[1] << endl;
    for (int i = 0; i < n; i++) {
      cout << e[a[i]] + 1 << " ";
      e[a[i]]++;
    }
  } else
    cout << -1 << endl;
}
