#include <bits/stdc++.h>
using namespace std;
int N, T, M, K;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int freq[100005];
  memset(freq, 0, sizeof freq);
  cin >> N;
  vector<int> V(N);
  int maxn = 0, ans = 0;
  for (int(i) = 0; (i) < (N); (i)++) {
    cin >> V[i];
    maxn = max(maxn, V[i]);
    freq[V[i]]++;
    ans = max(ans, freq[V[i]]);
  }
  int cur = freq[1];
  for (int i = 2; i <= maxn; i++) {
    if (freq[i] <= cur) {
      cur = freq[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  int occ[100005];
  memset(occ, 0, sizeof occ);
  cout << ans << endl;
  for (int i = 0; i < N; i++) {
    cout << (occ[V[i]]++) + 1 << " ";
  }
  cout << endl;
  return 0;
}
