#include <bits/stdc++.h>   using namespace std;   const long double pi = 3.1415926535897932384626433;   const long long inf = 1e18;   const long long mod = 1e9 + 7;   void solve() {     long long n;     cin >> n;     vector<long long> a(n);     vector<vector<long long> > cnt(100001);     long long me = 0;     for (long long i = 0; i < n; i++) {       cin >> a[i];       cnt[a[i]].push_back(i);       me = max(me, a[i]);     }     bool ok = 1;     for (long long i = me; i >= 2; i--) {       if (cnt[i].size() > cnt[i - 1].size()) {         ok = 0;         break;       }     }     if (!ok) {       cout <<  -1 n ;       return;     }     vector<long long> ans(n);     long long c = 0;     for (long long i = 1; i <= me; i++) {       long long k = 1;       for (auto x : cnt[i]) {         ans[x] = k;         k++;         c = max(c, k);       }     }     cout << c - 1 <<   n ;     for (long long i = 0; i < n; i++) {       cout << ans[i] <<    ;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t;     t = 1;     while (t--) {       solve();     }   }   