#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long a[n];
  long long max;
  map<long long, long long> m;
  long long maxer = -2;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
    if (maxer < a[i]) maxer = a[i];
  }
  max = -1;
  if (n == 1 && a[0] != 1) {
    cout << -1;
    return 0;
  }
  for (long long i = 0; i < n; i++)
    if (m[a[i]] > max) max = m[a[i]];
  for (auto it = m.begin(); it != m.end(); it++) {
    auto itr = next(it, 1);
    if (itr == m.end())
      break;
    else {
      if (itr->second > it->second) {
        cout << -1;
        return 0;
      }
    }
  }
  for (long long i = 1; i <= maxer; i++) {
    if (m[i] == 0) {
      cout << -1;
      return 0;
    }
  }
  cout << max << endl;
  for (long long i = 0; i < n; i++) {
    cout << m[a[i]] << " ";
    m[a[i]]--;
  }
}
