#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) { return a >= b ? a : b; }
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  map<long long, long long> make_pair;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) make_pair[a[i]]++;
  vector<long long> v;
  for (auto x : make_pair) v.push_back(x.second);
  for (long long i = 1; i < v.size(); i++) {
    if (v[i] - v[i - 1] > 0) {
      cout << -1;
      return;
    }
  }
  vector<long long> b;
  for (auto x : make_pair) b.push_back(x.first);
  long long c = 0;
  for (long long i = 1; i < b.size(); i++)
    if (b[i] - b[i - 1] == 1) c++;
  if (c != make_pair.size() - 1 || make_pair[1] == 0)
    cout << -1;
  else {
    cout << make_pair[1] << '\n';
    for (long long i = 0; i < n; i++) {
      cout << make_pair[a[i]] << " ";
      make_pair[a[i]]--;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
}
