#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000 * 100 + 1;
int main() {
  int i, n, a[maxN], b[maxN];
  memset(b, 0, sizeof(b));
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] > n) {
      cout << "-1\n";
      return 0;
    }
    ++b[a[i]];
  }
  for (i = 2; i <= n; ++i)
    if (b[i - 1] < b[i]) {
      cout << "-1\n";
      return 0;
    }
  cout << b[1] << endl;
  for (i = 1; i <= n; ++i) {
    cout << b[a[i]] << " ";
    --b[a[i]];
  }
  return 0;
}
