#include <bits/stdc++.h>
using namespace std;
int s[100100];
int a[100100];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) s[a[i]]++;
  int ok = 1;
  for (int i = 1; i <= 100000; i++) {
    if (s[i] < s[i + 1]) {
      ok = 0;
      break;
    }
  }
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }
  cout << s[1] << endl;
  for (int i = 0; i < n; i++) {
    cout << s[a[i]] << " ";
    s[a[i]]--;
  }
  return 0;
}
