#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 101 * 1001;
vector<int> a[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    a[x].push_back(i);
  }
  vector<int> res(n, -1);
  int m = N;
  int it = 0;
  while (m > 0) {
    while (m > 0 && !a[m].size()) m--;
    if (m <= 0) break;
    ++it;
    for (int i = m; i > 0; --i) {
      if (!a[i].size()) {
        return !printf("-1\n");
      }
      res[a[i][a[i].size() - 1]] = it;
      a[i].pop_back();
    }
  }
  cout << it << "\n";
  for (int i = 0; i < n; ++i) {
    printf("%d ", res[i]);
  }
  return 0;
}
