#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> values(n + 5, 0);
  int val;
  for (int i = 0; i < n; i++) {
    scanf("%d", &val);
    values[i + 1] = val;
  }
  vector<int> freq(n + 5, 0);
  for (int i = 0; i < n; i++) {
    int x = values[i + 1];
    if (x > n) {
      cout << -1 << endl;
      return 0;
    }
    freq[x]++;
    values[i + 1] = freq[x];
  }
  int v = freq[1];
  bool correct = true;
  for (int i = 2; i <= n; i++) {
    if (freq[i] > v) {
      correct = false;
      break;
    }
    v = freq[i];
  }
  if (correct) {
    cout << freq[1] << endl;
    for (int i = 1; i <= n; i++) {
      if (i == 1)
        cout << values[i];
      else
        cout << " " << values[i];
    }
    cout << endl;
  } else
    cout << -1 << endl;
  return 0;
}
