#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, elem, cur_total = 0;
  vector<int> shuffle, input, fin;
  shuffle.assign((int)1e5 + 1, 0);
  fin.assign((int)1e5 + 1, 1);
  scanf("%d", &n);
  input.assign(n, 0);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &input[i]);
    ++shuffle[input[i]];
  }
  for (int i = 1; i < shuffle.size() - 1; ++i) {
    if (shuffle[i] < shuffle[i + 1]) {
      printf("-1");
      return 0;
    }
  }
  printf("%d\n", shuffle[1]);
  for (int i = 0; i < input.size(); ++i) {
    printf("%d ", fin[input[i]]);
    ++fin[input[i]];
  }
  return 0;
}
