#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool uax(T &x, T y) {
  return (y > x) ? x = y, true : false;
}
template <typename T>
inline bool uin(T &x, T y) {
  return (y < x) ? x = y, true : false;
}
template <typename T>
void kek(T ans) {
  cout << ans << endl;
  exit(0);
}
const int MOD = (int)1e9 + 7;
const long long INF = (long long)1e18 + 42;
void solve_case() {
  int n;
  cin >> n;
  const int N = 1e5 + 42;
  vector<int> cnt(N), a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  for (int i = 1; i < N - 1; ++i) {
    if (cnt[i] < cnt[i + 1]) kek(-1);
  }
  cout << cnt[1] << '\n';
  for (int x : a) {
    cout << cnt[x] << ' ';
    cnt[x]--;
  }
}
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int tt = 1;
  while (tt--) {
    solve_case();
  }
}
