#include <bits/stdc++.h>
using namespace std;
int a[100010], mark[100010], pt[100010];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mark[a[i]]++;
  }
  for (int i = 1; i <= 100000; i++) {
    if (mark[i] < mark[i + 1]) {
      cout << "-1";
      return 0;
    }
    pt[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    a[i] = pt[a[i]]++;
  }
  cout << pt[1] - 1 << endl;
  for (int i = 0; i < n; i++) cout << a[i] << " ";
}
