#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000;
int n;
int per[MAXN];
int num[MAXN];
int main() {
  cin >> n;
  int maxPer = 0;
  for (int i = 0; i < n; i++) {
    cin >> per[i];
    num[per[i] - 1]++;
    if (maxPer < per[i]) {
      maxPer = per[i];
    }
  }
  for (int i = 1; i < maxPer; i++) {
    if (num[i] > num[i - 1]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << num[0] << endl;
  for (int i = 0; i < n; i++) {
    cout << num[per[i] - 1]-- << ' ';
  }
  cout << endl;
  return 0;
}
