#include <bits/stdc++.h>
using namespace std;
long long c[100005], ans;
long long solve() {
  long long n;
  cin >> n;
  vector<long long> v;
  for (long long i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    c[a]++;
    ans = max(ans, c[a]);
    v.push_back(c[a]);
  }
  for (long long i = 1; i < 100000; ++i) {
    if (c[i] < c[i + 1]) {
      cout << -1;
      return 0;
    }
  }
  cout << ans << "\n";
  for (long long i = 0; i < n; ++i) {
    cout << v[i] << " ";
  }
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
