#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   vector<int> cnt[N];   int res[N];   int main() {     int n;     while (cin >> n) {       for (int i = 1; i < N; i++) cnt[i].clear();       for (int i = 1; i <= n; i++) {         int v;         cin >> v;         cnt[v].push_back(i);       }       bool ok = true;       for (int i = 1; i < N; i++) {         if (i > 1 && cnt[i].size() > cnt[i - 1].size()) ok = false;         for (int j = 0; j < cnt[i].size(); j++) {           res[cnt[i][j]] = j + 1;         }       }       if (!ok) {         printf( %d n , -1);       } else {         printf( %d n , cnt[1].size());         for (int i = 1; i <= n; i++) printf( %d%c , res[i], i == n ?   n  :    );       }     }     return 0;   }   