#include <bits/stdc++.h>
using namespace std;
pair<int, int> L1[100000];
pair<int, int> L2[100000];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &L1[i].first);
    L1[i].second = i;
  }
  sort(L1, L1 + N);
  int idx = 1;
  int num = 1;
  int max_idx = 987654321;
  int one_cnt = 0;
  for (int i = 0; i < N; i++) {
    L2[i].first = L1[i].second;
    if (num == L1[i].first) {
      if (idx > max_idx) {
        printf("-1\n");
        return 0;
      }
      L2[i].second = idx++;
    } else {
      max_idx = min(max_idx, idx - 1);
      idx = 1;
      num++;
      i--;
      continue;
    }
    one_cnt += (L1[i].first == 1);
  }
  sort(L2, L2 + N);
  printf("%d\n", one_cnt);
  for (int i = 0; i < N; i++) {
    if (i != 0) printf(" ");
    printf("%d", L2[i].second);
  }
  printf("\n");
}
