#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 1e5 + 5;
int ans[N];
vector<int> conn[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    conn[x].push_back(i);
  }
  for (int i = 2; i <= 100000; i++)
    if (conn[i].size() > conn[i - 1].size()) return cout << "-1\n", 0;
  for (int i = 1; i <= 100000; i++) {
    for (int j = 0; j < conn[i].size(); j++) {
      ans[conn[i][j]] = j + 1;
    }
  }
  cout << conn[1].size() << "\n";
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
}
