#include <bits/stdc++.h>
using namespace std;
const int e9 = 1000 * 1000 * 1000;
const long long e18 = (long long)e9 * (long long)e9;
const double pi = 3.1415926535;
void pV(int num) { cout << num << " "; }
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
double rd() {
  double x;
  scanf("%lf", &x);
  return x;
}
long long rll() {
  long long x;
  scanf("%lld", &x);
  return x;
}
string rs() {
  string x;
  cin >> x;
  return x;
}
string rsf() {
  string s;
  char c;
  while (c = getchar()) {
    if (c >= 65 && c <= 90 || c >= 'a' && c <= 'z')
      s += c;
    else
      break;
  }
  return s;
}
void wi(int x) { printf("%d ", x); }
void wd(double x) { printf("%lf ", x); }
void wll(long long x) { printf("%lld ", x); }
void ws(string x) { cout << x << " "; }
int mas[105000];
int main() {
  int n = ri();
  map<int, int> gg;
  for (int i = (int)(1); i <= (int)(n); i++) {
    mas[i] = ri();
    gg[mas[i]]++;
  }
  bool ans = true;
  map<int, int>::iterator it;
  int last = -1;
  int ind = 1;
  for (it = gg.begin(); it != gg.end(); it++) {
    if (last == -1 && ind == it->first) {
      ind = 1;
      last = it->second;
    } else if (last == -1) {
      ans = false;
      break;
    } else if (it->first - ind == 1) {
      if (last < it->second) {
        ans = false;
        break;
      } else {
        last = it->second;
        ind = it->first;
      }
    } else {
      ans = false;
      break;
    }
  }
  if (!ans) {
    wi(-1);
    return 0;
  }
  wi(gg[1]);
  cout << endl;
  for (int i = (int)(1); i <= (int)(n); i++) {
    wi(gg[mas[i]]);
    gg[mas[i]]--;
  }
  return 0;
}
