#include <bits/stdc++.h>
using namespace std;
int res[100001];
int main() {
  int n, a[100001];
  set<int> s;
  set<int>::const_iterator it;
  vector<int> v[100001];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s.insert(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] > 100000) {
      cout << -1;
      return 0;
    }
  }
  it = s.end();
  it--;
  int mx = *it;
  for (int i = 1; i <= n; i++) {
    v[a[i]].push_back(i);
  }
  for (int i = 1; i < mx; i++) {
    if (v[i + 1].size() > v[i].size()) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 1; i <= mx; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      res[v[i][j]] = j + 1;
    }
  }
  cout << v[1].size() << endl;
  for (int i = 1; i <= n; i++) cout << res[i] << " ";
  return 0;
}
