#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a, b, i, n, maxi = 0, ani = 0;
  cin >> n;
  vector<int> vec(n);
  map<int, int> mp;
  for (i = 0; i < n; ++i) {
    cin >> a;
    ani = (a > ani ? a : ani);
    mp[a]++;
    maxi = (maxi > mp[a] ? maxi : mp[a]);
    vec[i] = mp[a];
  }
  for (i = 2; i < ani + 1; ++i) {
    if (mp[i] > mp[i - 1]) {
      cout << -1;
      return 0;
    }
  }
  cout << maxi << "\n";
  for (i = 0; i < n; ++i) {
    cout << vec[i] << " ";
  }
}
