#include <bits/stdc++.h>
using namespace std;
int s[100010];
int main() {
  int n;
  cin >> n;
  int a[n], mx = 0, ans[n], si = 0;
  for (int i = 0; i < n; i++)
    cin >> a[i], s[a[i]]++, mx = max(mx, a[i]), ans[i] = s[a[i]],
                            si = max(si, s[a[i]]);
  for (int i = 1; i <= mx; i++)
    if (s[i] < s[i + 1]) {
      cout << -1;
      return 0;
    }
  cout << si << endl;
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
