#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> seq[110000];
int res[110000];
int main() {
  scanf("%d", &n);
  int x;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    seq[i] = make_pair(x, i);
  }
  sort(seq, seq + n);
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1 || seq[i].first != seq[i + 1].first) {
      if (i < n - 1 && seq[i].first != seq[i + 1].first - 1) {
        printf("-1\n");
        return 0;
      }
      int j = i, cnt = 1;
      while (j > 0 && seq[j - 1].first == seq[j].first) {
        j--;
        cnt++;
      }
      if (cnt < ans) {
        printf("-1\n");
        return 0;
      }
      ans = max(cnt, ans);
      for (int k = j; k <= i; k++) res[seq[k].second] = k - j + 1;
    }
  }
  if (seq[0].first != 1) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", ans);
  printf("%d", res[0]);
  for (int i = 1; i < n; i++) printf(" %d", res[i]);
  printf("\n");
}
