#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> v[i];
  }
  std::vector<std::vector<int> > a(100001);
  for (int i = 0; i < n; ++i) {
    a[v[i]].push_back(i);
  }
  int num = a[1].size();
  if (num == 0) {
    std::cout << -1 << std::endl;
    return 0;
  }
  for (int i = 2; i < (int)a.size(); ++i) {
    if (num < (int)a[i].size()) {
      std::cout << -1 << std::endl;
      return 0;
    } else {
      num = a[i].size();
    }
  }
  std::vector<int> res(n);
  for (int i = 1; i < (int)a.size(); ++i) {
    for (int j = 0; j < (int)a[i].size(); ++j) {
      res[a[i][j]] = j + 1;
    }
  }
  std::cout << a[1].size() << std::endl;
  std::copy(res.begin(), res.end(), std::ostream_iterator<int>(std::cout, " "));
  std::cout << std::endl;
}
