#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int mid, n;
int cnt[MAXN];
int a[MAXN][2];
bool flag = true;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i][0];
    if (a[i][0] > mid) mid = a[i][0];
    cnt[a[i][0]]++;
    a[i][1] = cnt[a[i][0]];
  }
  for (int i = 1; i <= mid - 1; i++)
    if (cnt[i] < cnt[i + 1]) {
      flag = false;
      break;
    }
  if (flag) {
    cout << cnt[1] << endl;
    for (int i = 0; i < n; i++) cout << a[i][1] << " ";
  } else
    cout << -1 << endl;
  return 0;
}
