#include <bits/stdc++.h>
template <typename T>
inline void SWAP(T &a, T &b) {
  T tmp = a;
  a = b;
  b = tmp;
}
template <typename T>
inline T ABS(const T &val) {
  return val < 0 ? -val : val;
}
template <typename T>
inline T MAX(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
inline T MIN(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
inline T SQR(const T &a) {
  return a * a;
}
const int INTinf = 1000000000;
const int nINTinf = 0 - 2147483648;
const long long LLinf = 9223372036854775807LL;
using namespace std;
int n;
int a[100005];
int mass[100005];
int mass2[100005];
int main() {
  cin >> n;
  int MX = 0;
  for (int i = 0; i != n; i++) {
    cin >> a[i];
    MX = (MX > a[i] ? MX : a[i]);
    mass[a[i]]++;
  }
  for (int i = 1; i <= MX; i++) {
    if (mass[i] < mass[i + 1]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << mass[1] << endl;
  for (int i = 0; i != n; i++) {
    cout << ++mass2[a[i]] << ' ';
  }
  cout << endl;
  return 0;
}
