#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
const int DIRX[] = {-1, 0, 0, 1, -1, -1, 1, 1},
          DIRY[] = {0, -1, 1, 0, -1, 1, -1, 1};
const double ERR = 1e-9, PI = (2 * acos(0.0));
template <class T>
inline int size(T& t) {
  return (int)t.size();
}
template <class T>
inline T MIN(T a, T b) {
  return ((a < b) ? a : b);
}
template <class T>
inline T MAX(T a, T b) {
  return ((b < a) ? a : b);
}
template <class T>
inline void checkMIN(T& a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkMAX(T& a, T b) {
  if (a < b) a = b;
}
template <class T>
inline T sqr(T x) {
  return (x * x);
}
int compareDouble(double x, double y) {
  double d = x - y;
  if (d > ERR) return 1;
  if (d < -ERR) return -1;
  return 0;
}
int compareDouble(double x, double y, double err) {
  double d = x - y;
  if (d > err) return 1;
  if (d < -err) return -1;
  return 0;
}
int a[100005], freq[100005];
int main() {
  int n, m, i, tot;
  cin >> n;
  m = 0;
  for (i = 0; i < (int)(n); i++) {
    cin >> a[i];
    freq[a[i]]++;
    if (a[i] > m) m = a[i];
  }
  tot = 0;
  for (i = m; i > 0; i--) {
    if (freq[i] < freq[i + 1]) {
      cout << (-1);
      return 0;
    }
    if (freq[i] > freq[i + 1]) {
      tot += (freq[i] - freq[i + 1]);
    }
  }
  cout << tot << endl;
  for (i = 0; i < (int)(n); i++) {
    cout << (freq[a[i]]--) << " ";
  }
  return 0;
}
