#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
vector<int> adj[100009];
int ans[100009], cnt[100009];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    adj[x].push_back(i);
    cnt[x]++;
  }
  int res = 0;
  while (cnt[1]) {
    res++;
    for (int i = 1; i < 100009; i++) {
      if (!cnt[i]) break;
      ans[adj[i].back()] = res;
      adj[i].pop_back();
      cnt[i]--;
    }
  }
  if (*max_element(cnt + 1, cnt + 100009) == 0) {
    printf("%d\n", res);
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    puts("");
  } else
    puts("-1");
  return 0;
}
