#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
bool prime[1000001];
vector<int> v1;
void sieve() {
  memset(prime, true, sizeof(prime));
  for (int i = 2; i * i <= 1000000; i++)
    if (prime[i])
      for (int j = i * i; j <= 1000000; j += i) prime[j] = false;
  prime[0] = prime[1] = false;
}
int main() {
  int n;
  cin >> n;
  map<int, int> mp1;
  int max1 = 0;
  int mm = 0;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mm = max(mm, a[i]);
    mp1[a[i]]++;
    max1 = max(max1, mp1[a[i]]);
  }
  int cnt1 = 1;
  for (int i = 2; i < mm + 1; i++) {
    if (mp1[i] <= mp1[i - 1]) {
    } else {
      cnt1 = 2;
      break;
    }
  }
  if (cnt1 == 2) {
    cout << "-1\n";
    return 0;
  }
  cout << max1 << endl;
  for (int i = 0; i < n; i++) {
    cout << mp1[a[i]] << " ";
    mp1[a[i]]--;
  }
  cout << endl;
  return 0;
}
