#include <bits/stdc++.h>
using namespace std;
bool cmp(const pair<int, vector<int>>& a, const pair<int, vector<int>>& b) {
  if (a.first == b.first) {
    return a.second < b.second;
  }
  return a.first > b.first;
}
void solve() {
  int n;
  cin >> n;
  int mark[100005] = {};
  vector<int> v[100005];
  int Count = n;
  for (int i = 1; i <= n; i++) {
    int tem;
    cin >> tem;
    v[tem].push_back(i);
  }
  bool ok = true;
  int per = 1;
  while (v[1].size() > 0) {
    for (int i = 1; i <= 100000; i++) {
      if (v[i].size() == 0) {
        break;
      }
      int p = v[i][0];
      v[i].erase(v[i].begin());
      Count--;
      mark[p] = per;
    }
    per++;
  }
  if (Count > 0) {
    cout << "-1" << endl;
    return;
  }
  cout << per - 1 << endl;
  for (int i = 1; i <= n; i++) {
    cout << mark[i] << " ";
  }
  cout << endl;
}
int main() {
  solve();
  return 0;
}
