#include <bits/stdc++.h>
using namespace std;
const int MN = 1000 * 100 + 100;
int ans[MN], cnt[MN];
struct block {
  int el, k;
  bool operator<(const block &nw) const { return (el < nw.el); }
};
block a[MN];
int main() {
  int n, k = 0, m = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].el);
    a[i].k = i;
    cnt[a[i].el]++;
    k = max(k, a[i].el);
    m = max(m, cnt[a[i].el]);
  }
  for (int i = 2; i <= k; i++) {
    if (!cnt[1] || !cnt[i] || cnt[i] > cnt[i - 1]) {
      cout << "-1";
      return 0;
    }
  }
  for (int i = 0; i < n; i++) ans[i] = cnt[a[i].el]--;
  cout << m << endl;
  for (int i = 0; i < n; i++) printf("%d ", ans[i]);
  return 0;
}
