#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
int freq[100005], a[100005];
void solve() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    freq[arr[i]]++;
    a[arr[i]] = 1;
  }
  for (int i = 2; i <= 100001; i++) {
    if (freq[i] > freq[i - 1]) {
      cout << "-1";
      return;
    }
  }
  cout << freq[1] << endl;
  for (int i = 0; i < n; i++) {
    cout << a[arr[i]] << " ";
    a[arr[i]]++;
  }
}
int main() {
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
