#include <bits/stdc++.h>
using namespace std;
queue<int> q[100005];
int num[100005];
int n, a[100005], maxx = -1, k = 0;
bool anss = true;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    maxx = max(maxx, a[i]);
    num[a[i]]++;
  }
  for (int i = maxx; i > 0; --i) {
    while (num[i]) {
      if (!num[i]) continue;
      k++;
      for (int j = 1; j <= i; ++j) {
        if (!num[j]) {
          anss = false;
          break;
        }
        num[j]--;
        q[j].push(k);
      }
      if (!anss) break;
    }
    if (!anss) break;
  }
  if (!anss) {
    cout << "-1" << endl;
    return 0;
  }
  cout << k << endl;
  for (int i = 1; i <= n; ++i) {
    printf("%d ", q[a[i]].front());
    q[a[i]].pop();
  }
  return 0;
}
