#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 10;
int arr[MAXN], t[MAXN];
int main() {
  int n;
  cin >> n;
  int mx = 1;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    t[arr[i]]++;
    mx = max(mx, arr[i]);
  }
  for (int i = 1; i < mx; i++)
    if (t[i] < t[i + 1]) {
      cout << "-1\n";
      return 0;
    }
  cout << t[1] << endl;
  for (int j = 0; j < n; j++) {
    cout << t[arr[j]] << " ";
    t[arr[j]]--;
  }
  cout << endl;
}
