#include <bits/stdc++.h>
using namespace std;
int nums[100005];
int counting[100005];
int ans[100005];
int solve(int n) {
  for (int a = (1); a < (100005 - 1); a++) {
    if (counting[a] < counting[a + 1]) return -1;
  }
  for (int a = (0); a < (100005); a++) counting[a] = 0;
  for (int a = (0); a < (n); a++) {
    counting[nums[a]]++;
    ans[a] = counting[nums[a]];
  }
  return counting[1];
}
int main() {
  int n;
  cin >> n;
  for (int a = (0); a < (n); a++) cin >> nums[a];
  for (int a = (0); a < (n); a++) counting[a] = 0;
  for (int a = (0); a < (n); a++) counting[nums[a]]++;
  int myon = solve(n);
  cout << myon << endl;
  if (myon != -1) {
    for (int a = (0); a < (n); a++) {
      cout << ans[a];
      if (a != n - 1)
        cout << " ";
      else
        cout << endl;
    }
  }
  return 0;
}
