#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], b[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    a[b[i]]++;
  }
  int ans = 0;
  for (int i = 1; i < maxn - 1; i++) {
    if (a[i + 1] > a[i]) {
      puts("-1");
      return 0;
    }
  }
  cout << a[1] << endl;
  for (int i = 1; i <= n; i++) {
    cout << a[b[i]]-- << " ";
  }
  return 0;
}
