#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int inf = (int)1e9;
const long long int infll = (long long int)1e18;
const double inf1 = 1e-9;
const int ss = (int)1e6 + 3;
const int base = inf;
bool pred(const pair<int, int>& i, const pair<int, int>& j) {
  if (i.first == j.first)
    return i.second > j.second;
  else
    return i.first > j.first;
}
bool pred2(const int& i, const int& j) { return i > j; }
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  int k = 100001;
  vector<vector<int> > b(k);
  int mx = -1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    b[a[i]].push_back(i);
    mx = max(a[i], mx);
  }
  if (mx == 1) {
    cout << b[1].size() << endl;
    for (int i = 0; i < n; ++i) cout << i + 1 << " ";
    return 0;
  }
  bool t = true;
  for (int j = 2; j <= mx; ++j) {
    if (b[j].size() > b[j - 1].size()) {
      t = false;
      break;
    }
  }
  if (!t) {
    cout << "-1";
    return 0;
  }
  cout << b[1].size() << endl;
  vector<int> c(n);
  for (int i = 1; i <= mx; ++i) {
    for (int j = 0; j < b[i].size(); ++j) c[b[i][j]] = j + 1;
  }
  for (int i = 0; i < n; ++i) cout << c[i] << " ";
  return 0;
}
