#include <bits/stdc++.h>
using namespace std;
int n, a[100005], ans[100005], maxi, maxiii;
vector<int> f[100005];
int main() {
  int i, j, ok = 1;
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    f[a[i]].push_back(i);
    maxi = max(a[i], maxi);
  }
  for (i = 1; (i < maxi) && ok; i++)
    if (f[i].size() < f[i + 1].size()) ok = 0;
  if (!ok) {
    cout << -1;
    return 0;
  }
  maxiii = 0;
  for (i = 1; i <= maxi; i++) {
    j = 0;
    for (auto x : f[i]) {
      j++;
      ans[x] = j;
    }
    maxiii = max(maxiii, j);
  }
  cout << maxiii << "\n";
  for (i = 1; i <= n; i++) cout << ans[i] << ' ';
  return 0;
}
