#include <bits/stdc++.h>
using namespace std;
void open() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int perm[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  pair<int, int> sk[n];
  for (int j = 0; j < n; j++) {
    cin >> sk[j].first;
    sk[j].second = j;
  }
  sort(sk, sk + n);
  int rez[n];
  int l = 1;
  int an = 0;
  for (int j = 0; j < n; j++) {
    if (sk[j].first != l) {
      cout << -1;
      exit(0);
    }
    int cnt = 1;
    while (sk[j].first == l) {
      if (sk[j].first - perm[cnt] != 1) {
        cout << -1;
        exit(0);
      }
      rez[sk[j].second] = cnt;
      perm[cnt] = l;
      an = max(an, cnt);
      cnt++;
      j++;
    }
    j--;
    l++;
  }
  cout << an << "\n";
  for (int j = 0; j < n; j++) cout << rez[j] << " ";
  return 0;
}
