#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  vector<int> p(n), ans(n), kol(n + 1, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
    if (a[i].first > n) {
      cout << -1 << '\n';
      return 0;
    }
    ++kol[a[i].first];
  }
  sort(a.begin(), a.end());
  for (int j = 2; j <= n; ++j)
    if (kol[j] > kol[j - 1]) {
      cout << -1 << '\n';
      return 0;
    }
  int mx = 1;
  for (int i = 0; i < n; ++i) {
    int x = 1;
    ans[a[i].second] = 1;
    while (i + 1 < n && a[i].first == a[i + 1].first) {
      ++i;
      ++x;
      ans[a[i].second] = x;
    }
    if (x > mx) mx = x;
  }
  cout << mx << '\n';
  for (int i = 0; i < n; ++i) cout << ans[i] << ' ';
  return 0;
}
