#include <bits/stdc++.h>
using namespace std;
int arr[100001];
int dp[100001];
int main() {
  int n;
  scanf("%d", &n);
  memset(dp, 0, sizeof dp);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    dp[arr[i]]++;
  }
  for (int i = 2; i <= 100000; i++) {
    if (dp[i] > dp[i - 1]) {
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << dp[1] << endl;
  for (int i = 0; i < n; i++) {
    cout << dp[arr[i]] << " ";
    dp[arr[i]]--;
  }
  cout << endl;
}
