#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
vector<string> alpha{"a", "b", "c", "d", "e", "f", "g", "h", "i",
                     "j", "k", "l", "m", "n", "o", "p", "q", "r",
                     "s", "t", "u", "v", "w", "x", "y", "z"};
int GDC(int a, int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  return GDC(b, a % b);
}
int LCD(int a, int b) {
  if (a == b) return a;
  if (max(a, b) % min(a, b) == 0) return max(a, b);
  return a * b;
}
int search(vector<int> a, int b) {
  int m = a.size() / 2;
  vector<int> h;
  int i = -1;
  if (b == a[m]) return m;
  if (a.size() == 1 && b != a[m]) return -1;
  if (b < a[m]) {
    h = {a.begin(), a.begin() + m};
    i = 0;
  } else {
    h = {a.begin() + m, a.end()};
    i = m;
  }
  int s = search(h, b);
  return s < 0 ? -1 : i + s;
}
int searchU(vector<int> a, int b) {
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == b) return i;
  }
  return -1;
}
int min(vector<int> a) {
  int best = pow(2, 31) - 1;
  for (auto b : a) {
    if (b < best) best = b;
  }
  return best;
}
int max(vector<int> a) {
  int best = 0;
  for (auto b : a) {
    if (b > best) best = b;
  }
  return best;
}
void printVector(vector<int> v) {
  for (auto i : v) {
    cout << i << " ";
  }
  cout << '\n';
}
bool in(int val, vector<int> v) {
  for (auto i : v) {
    if (i == val) {
      return true;
    }
  }
  return false;
}
int sum(vector<int> v) {
  int sum = 0;
  for (auto i : v) {
    sum += i;
  }
  return sum;
}
int main() {
  int cases = 1;
  for (int _case = 0; _case < cases; _case++) {
    int n;
    cin >> n;
    vector<int> nums = {0};
    vector<int> a;
    for (int i = 0; i < n; i++) {
      int val;
      cin >> val;
      a.push_back(val);
      nums.push_back(0);
    }
    if (max(a) >= nums.size()) {
      for (int i = nums.size() - 1; i < max(a); i++) {
        nums.push_back(0);
      }
    }
    vector<int> b;
    for (int i = 0; i < n; i++) {
      nums[a[i]]++;
      b.push_back(nums[a[i]]);
    }
    bool x = false;
    for (int i = 2; i < nums.size(); i++) {
      if (nums[i] > nums[i - 1]) {
        cout << -1 << '\n';
        x = true;
        break;
      }
    }
    if (!x) {
      cout << max(b) << '\n';
      printVector(b);
    }
  }
}
