#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  int a[n + 1];
  for (i = 0; i < n; i++) cin >> a[i];
  int m = a[0];
  for (i = 1; i < n; i++) m = max(m, a[i]);
  int cnt[m + 1];
  for (i = 1; i <= m; i++) cnt[i] = 0;
  for (i = 0; i < n; i++) cnt[a[i]]++;
  for (i = 1; i <= m - 1; i++) {
    if (cnt[i] < cnt[i + 1]) break;
  }
  if (i < m)
    cout << "-1"
         << "\n";
  else {
    int cnt1[m + 1];
    for (i = 0; i < n; i++) cnt1[a[i]] = 1;
    int cnt2 = 0;
    vector<int> v;
    for (i = 0; i < n; i++) {
      v.push_back(cnt1[a[i]]);
      cnt2++;
      cnt1[a[i]]++;
    }
    set<int> s;
    for (i = 0; i < v.size(); i++) {
      s.insert(v[i]);
    }
    cout << s.size() << "\n";
    for (i = 0; i < v.size(); i++) cout << v[i] << " ";
  }
}
