#include <bits/stdc++.h>
using namespace std;
double esp = 1e-9;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
int dx[4] = {1, 1, -1, -1};
int dy[4] = {1, -1, 1, -1};
int s[110010];
int q[110010];
int main() {
  int n, t;
  memset(s, 0, sizeof(s));
  memset(q, 0, sizeof(q));
  scanf("%d", &n);
  for (int x = 1; x <= n; x++) {
    scanf("%d", &s[x]);
    q[s[x]]++;
  }
  int flag = 0;
  for (int x = 2; x <= 100000; x++)
    if (q[x] > q[x - 1]) {
      flag = 1;
      break;
    }
  int ans = q[1];
  memset(q, 0, sizeof(q));
  if (flag)
    printf("%d\n", -1);
  else {
    printf("%d\n", ans);
    for (int x = 1; x <= n; x++) printf("%d ", ++q[s[x]]);
  }
  return 0;
}
