#include <bits/stdc++.h>
using namespace std;
int n, arr[100005], has[100005], t;
vector<int> v[100005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    arr[a]++;
    has[i] = arr[a];
    v[has[i]].push_back(a);
    t = max(t, has[i]);
  }
  for (int i = 0; i < 100000; i++) {
    int p = v[i].size();
    if (p != 0) {
      int tmp = 0;
      for (int j = 0; j < p; j++) {
        tmp += v[i][j];
      }
      if (tmp != ((p * (p + 1)) / 2)) {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  cout << t << endl;
  for (int i = 1; i <= n; i++) cout << has[i] << " ";
  cout << endl;
}
