#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long mp[N], curr[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long T = 1;
  while (T--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      mp[a[i]]++;
    }
    for (long long i = 2; i < N; i++) {
      if (mp[i] > mp[i - 1]) {
        cout << "-1\n";
        return 0;
      }
    }
    cout << mp[1] << '\n';
    for (long long i = 0; i < n; i++) {
      cout << ++curr[a[i]] << ' ';
    }
    cout << '\n';
  }
  return 0;
}
