#include <bits/stdc++.h>
using namespace std;
const int max_N = 100000 + 20;
int a[max_N], cnt1[max_N], cnt2[max_N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt1[a[i]]++;
    cnt2[a[i]]++;
  }
  for (int i = 1; i <= 100000; i++) {
    if (cnt1[i] < cnt1[i + 1]) {
      cout << -1;
      return 0;
    }
    cnt2[i]--;
  }
  cout << cnt1[1] << endl;
  for (int i = 0; i < n; i++) {
    cout << cnt1[a[i]] - cnt2[a[i]] << " ";
    cnt2[a[i]]--;
  }
  return 0;
}
