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