#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n], c[n];
  int max = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > n) {
      cout << "-1";
      return 0;
    }
    if (a[i] > max) max = a[i];
  }
  int b[max], k[max];
  for (int i = 0; i < max; i++) {
    b[i] = 0;
    k[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    b[a[i] - 1]++;
  }
  for (int i = 1; i < max; i++) {
    if (b[i] > b[i - 1] || b[i] == 0) {
      cout << "-1";
      return 0;
    }
  }
  for (int j = 0; j < n; j++) {
    c[j] = k[a[j] - 1]++;
  }
  cout << b[0] << endl;
  for (int i = 0; i < n; i++) cout << c[i] << " ";
  return 0;
}
