#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  static int buc[100001];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    buc[a[i]]++;
  }
  bool ok = true;
  int mx = *max_element(a.begin(), a.end()), m = 0;
  for (int i = mx; i >= 1; i--) {
    buc[i] -= m;
    if (buc[i] < 0) {
      ok = false;
      break;
    }
    m += buc[i];
  }
  if (!ok) {
    puts("-1");
    return 0;
  }
  printf("%d\n", m);
  static int cnt[100001];
  for (int i = 0; i < n; i++) {
    if (i > 0) putchar(' ');
    printf("%d", ++cnt[a[i]]);
  }
  return 0;
}
