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