#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10;
int ar[MAXn], ar2[MAXn], n, ans[MAXn];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ar2[a]++;
    ans[i] = ++ar[a];
  }
  for (int i = 1; i < MAXn - 1; i++)
    if (ar2[i] < ar2[i + 1]) return cout << -1, 0;
  cout << ar2[1] << endl;
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
}
