#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int cnt[100001];
  pair<int, int> p[n];
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; i++) {
    cin >> p[i].first;
    p[i].second = i;
    cnt[p[i].first]++;
  }
  sort(p, p + n);
  for (int i = 2; i <= 1e5; i++) {
    if (cnt[i] > cnt[i - 1]) {
      cout << -1;
      return 0;
    }
  }
  int cur, pr = 0, q;
  int a[n], ans = 0;
  for (int i = 0; i < n; i++) {
    cur = p[i].first;
    if (cur != pr) {
      q = 1;
    }
    a[p[i].second] = q++;
    ans = max(ans, q - 1);
    pr = cur;
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
