#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, j;
  cin >> n;
  long long int a[n];
  vector<long long int> v[n + 1];
  map<long long int, long long int> mp;
  long long int maxi = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > maxi) maxi = a[i];
    mp[a[i]]++;
  }
  long long int cnt = mp[1];
  for (i = 2; i <= maxi; i++) {
    if (mp[i] > mp[i - 1]) {
      cout << "-1\n";
      return 0;
    }
  }
  cout << cnt << "\n";
  for (i = 1; i <= n; i++) {
    for (j = mp[i]; j >= 1; j--) v[i].push_back(j);
  }
  for (i = 0; i < n; i++) {
    cout << *(v[a[i]].end() - 1) << " ";
    v[a[i]].pop_back();
  }
}
