#include <bits/stdc++.h>
using namespace std;
int n;
map<int, vector<int>> m;
int result[100001];
int a[100001];
int need[100001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    a[i] = k;
    if (m.count(k) == 0) m[k] = vector<int>();
    m[k].push_back(i);
  }
  auto it1 = m.begin();
  if (it1->first != 1) {
    cout << -1;
    return 0;
  }
  it1++;
  for (auto it = m.begin(); it != m.end(); it++, it1++) {
    if (it1 != m.end()) {
      if (it1->first != it->first + 1) {
        cout << -1;
        return 0;
      }
      if (it1->second.size() > it->second.size()) {
        cout << -1;
        return 0;
      }
    } else
      break;
  }
  cout << m.begin()->second.size() << endl;
  for (int i = 1; i <= n; i++) need[i] = 1;
  for (int i = 0; i < n; i++) {
    cout << need[a[i]]++ << " ";
  }
  return 0;
}
