#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, temp;
  cin >> n;
  map<int, int> mp;
  int maxu = INT_MIN, maxNo = -1;
  vector<int> arr(n + 1);
  for (long long int i = 1; i <= n; ++i) {
    cin >> temp;
    mp[temp] += 1;
    maxu = max(maxu, mp[temp]);
    maxNo = max(temp, maxNo);
    arr[i] = temp;
  }
  for (long long int i = 1; i <= maxNo - 1; ++i) {
    if ((mp[i] == 0 || mp[i + 1] == 0) || mp[i] < mp[i + 1]) {
      cout << -1 << endl;
      exit(0);
    }
  }
  vector<vector<int> > positions(maxNo + 1);
  for (long long int i = 1; i <= n; ++i) {
    positions[arr[i]].push_back(i);
  }
  cout << maxu << endl;
  vector<int> ans(n + 1, 0);
  for (long long int i = 1; i <= maxNo; ++i) {
    auto x = positions[i];
    temp = mp[i];
    for (int p : x) {
      if (temp > 0) {
        ans[p] = temp;
        temp -= 1;
      }
    }
  }
  for (long long int i = 1; i <= n; ++i) {
    cout << ans[i] << " ";
  }
  return 0;
}
