#include <bits/stdc++.h>
using namespace std;
int a[100020], n, maxn, b[100020];
bool check;
int main(void) {
  int c[100020];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    a[c[i]]++;
    maxn = maxn > c[i] ? maxn : c[i];
  }
  for (int i = maxn; i > 1; i--) {
    if (a[i] > a[i - 1]) check = true;
  }
  if (check)
    cout << "-1" << endl;
  else {
    cout << a[1] << endl;
    for (int i = 0; i < n; i++) cout << ++b[c[i]] << " ";
    cout << endl;
  }
  return 0;
}
