#include <bits/stdc++.h>
using namespace std;
int main() {
  int mass[100005];
  int mass1[100005];
  int n, i;
  cin >> n;
  for (i = 1; i <= 100003; i++) mass1[i] = 0;
  for (i = 0; i < n; i++) {
    cin >> mass[i];
    mass1[mass[i]]++;
  }
  for (i = 1; i <= 100002; i++)
    if (mass1[i] < mass1[i + 1]) {
      cout << -1 << endl;
      return 0;
    }
  cout << mass1[1] << endl;
  for (i = 0; i < n; i++) {
    cout << mass1[mass[i]] << " ";
    mass1[mass[i]]--;
  }
  return 0;
}
