#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<set<int>> vs(n);
  map<int, int> mp;
  int mx = 0;
  for (auto i : v) vs[mp[i]++].insert(i), mx = max(mx, mp[i]);
  bool good = 1;
  for (auto i : vs) {
    int cnt = 1;
    for (auto j : i) {
      if (j != cnt) good = 0;
      cnt++;
    }
  }
  mp.clear();
  if (good) {
    cout << mx << endl;
    for (auto i : v) cout << ++mp[i] << " ";
  } else
    cout << -1;
}
