#include <bits/stdc++.h>
using namespace std;
const long double epsylon = 1e-9;
int cnt[100010];
int br[100010];
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> brs;
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }
  for (int i = 1; i < 100002; ++i) {
    if (cnt[i + 1] > cnt[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << cnt[1] << endl;
  memset(br, 0, sizeof(br));
  for (int i = 0; i < n; ++i) {
    printf("%d%c", ++br[a[i]], ((i == n - 1) ? '\n' : ' '));
  }
  return 0;
}
