#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> m(n);
  int mmax = 0;
  map<int, int> book;
  for (int i = 0; i < n; i++) {
    cin >> m[i];
    mmax = max(mmax, m[i]);
    book[m[i]]++;
  }
  int wina = n + 1;
  for (int i = 1; i <= mmax; i++) {
    if (book[i] > wina) {
      cout << -1 << endl;
      return 0;
    }
    wina = book[i];
  }
  int ans = book[1];
  vector<int> mmm(n);
  for (int i = 0; i < n; i++) {
    mmm[i] = book[m[i]];
    book[m[i]]--;
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) cout << mmm[i] << " ";
  cout << endl;
  return 0;
}
