#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
bool cmp(int a, int c) { return arr[a] < arr[c]; }
int main() {
  int n, res = -1;
  cin >> n;
  vector<int> b(n), ans(n), list, am;
  arr.resize(n);
  for (int k = 0; k < n; k++) {
    cin >> arr[k];
    b[k] = k;
    if (arr[k] > (int)am.size() - 1) {
      am.resize(arr[k] + 1);
    }
    am[arr[k]]++;
    res = max(res, am[arr[k]]);
  }
  for (int k = 2; k < (int)am.size(); k++) {
    if (am[k] > am[k - 1]) {
      cout << -1;
      return 0;
    }
  }
  sort(b.begin(), b.end(), cmp);
  int i;
  for (int k = 0, i = 0; k < n; k++, i++) {
    if (k == 0 || arr[b[k - 1]] != arr[b[k]]) {
      i = 0;
    }
    ans[b[k]] = i + 1;
  }
  cout << res << '\n';
  for (int k = 0; k < n; k++) {
    cout << ans[k] << " ";
  }
  cout << '\n';
  return 0;
}
