#include <bits/stdc++.h>
const int MAXN = 100007;
using namespace std;
int count_[MAXN], res[MAXN];
int n;
vector<int> id[MAXN];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int u;
    cin >> u;
    count_[u]++;
    id[u].push_back(i);
  }
  int i = 1;
  int j = 1;
  for (int t = 1; t <= n; t++) {
    if (id[j].size() == 0) {
      cout << -1;
      return 0;
    }
    int x = id[j].back();
    id[j].pop_back();
    res[x] = i;
    j++;
    if (id[j].size() == 0) {
      i++;
      j = 1;
    }
  }
  cout << i - 1 << endl;
  for (int t = 1; t <= n; t++) cout << res[t] << " ";
}
