#include <bits/stdc++.h>
using namespace std;
int arr[100005], permu[100005];
map<int, int> mp;
int main() {
  int n, mx = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i], mp[arr[i]]++, permu[i] = mp[arr[i]], mx = max(mx, arr[i]);
  }
  for (int i = 2; i <= mx; i++) {
    if (mp[i] > mp[i - 1] || mp[i] == 0) {
      puts("-1");
      return 0;
    }
  }
  if (mp[1] == 0) {
    puts("-1");
    return 0;
  }
  cout << mp[1] << "\n";
  for (int i = 0; i < n; i++) {
    cout << permu[i] << " ";
  }
  return 0;
}
