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