#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  bool b = true;
  scanf("%d", &n);
  int arr[100001];
  for (int i = 0; i < 100001; i++) {
    arr[i] = 0;
  }
  vector<pair<int, int> > v;
  v.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i].first);
    arr[v[i].first]++;
    v[i].second = arr[v[i].first];
  }
  for (int i = 1; i < 100000; i++) {
    if (arr[i] < arr[i + 1]) {
      b = false;
      break;
    }
  }
  if (!b) {
    cout << -1;
  } else {
    cout << arr[1] << endl;
    for (int i = 0; i < n; i++) {
      cout << v[i].second << " ";
    }
  }
}
