#include <bits/stdc++.h>
using namespace std;
int main() {
  int max1 = 1e5 + 2;
  int count[max1];
  int index[max1];
  for (int i = 0; i < max1; i++) {
    count[i] = 0;
    index[i] = 1;
  }
  int n;
  cin >> n;
  int* arr = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    count[arr[i]]++;
  }
  int top = 0;
  for (int i = 1; i < max1 - 1; i++) {
    if (count[i] < count[i + 1]) {
      cout << -1 << endl;
      return 0;
    }
    top = max(top, count[i]);
  }
  cout << top << endl;
  for (int i = 0; i < n; i++) {
    cout << index[arr[i]] << " ";
    index[arr[i]]++;
  }
  cout << endl;
  return 0;
}
