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