#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> a[100100];
int r[100100];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    a[i] = make_pair(x, i);
  }
  sort(a, a + n);
  int id = 1000000;
  int last = 1000000;
  int ret = -1;
  int val = 0;
  for (int i = 0; i < n; ++i) {
    if (i == 0 || a[i].first != a[i - 1].first) {
      ++val;
      if (id > last || a[i].first != val) {
        cout << -1 << endl;
        return 0;
      }
      last = id;
      if (id != 1000000) {
        ret = max(ret, id);
      }
      id = 0;
    }
    ++id;
    r[a[i].second] = id;
  }
  if (id != 1000000) {
    ret = max(ret, id);
  }
  cout << ret << endl;
  for (int i = 0; i < n; ++i) {
    cout << r[i] << " ";
  }
  return 0;
}
