#include <bits/stdc++.h>
using namespace std;
void run_case() {
  long long n;
  cin >> n;
  vector<long long> a(n, 0);
  for (long long i = 0; i < n; i++) cin >> a[i];
  map<long long, long long> mp;
  for (long long i = 0; i < n; i++) {
    mp[a[i]]++;
  }
  auto chk = [&](map<long long, long long> m) {
    long long mx = *max_element((a).begin(), (a).end());
    long long las = mp[1];
    long long lasele = 1;
    while (lasele <= mx) {
      if (mp[lasele] > las)
        return 0;
      else {
        las = mp[lasele];
        lasele++;
      }
    }
    return 1;
  };
  if (chk(mp) == 0) {
    cout << -1 << '\n';
  } else {
    map<long long, long long> las;
    for (auto& ix : a) {
      las[ix] = 1;
    }
    long long ans[n];
    for (long long i = 0; i < n; i++) {
      ans[i] = las[a[i]];
      las[a[i]]++;
    }
    cout << mp[1] << '\n';
    for (auto& ix : ans) {
      cout << ix << " ";
    }
    cout << '\n';
    ;
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(20);
  long long tests = 1;
  for (long long tt = 1; tt <= tests; tt++) {
    run_case();
  }
  return 0;
}
