#include <bits/stdc++.h>   using namespace std;   struct node {     long k, na;   };   const long maxn = 100001;   node a[maxn];   long n, b[maxn];   int qsort(long low, long high) {     long i = low, j = high, x = a[(i + j) / 2].k;     while (i < j) {       while (a[i].k < x) i++;       while (a[j].k > x) j--;       if (i <= j) {         swap(a[i], a[j]);         i++;         j--;       }     }     if (i < high) qsort(i, high);     if (j > low) qsort(low, j);     return 0;   }   void init() {     cin >> n;     for (long i = 1; i <= n; i++) {       cin >> a[i].k;       a[i].na = i;     }     qsort(1, n);   }   void work() {     memset(b, 0, sizeof(b));     for (long i = 1; i <= n; i++) b[a[i].k] += 1;     int bj = 1;     for (long i = 2; i <= a[n].k; i++)       if (b[i] > b[i - 1]) bj = 0;     if (bj) {       cout << b[1] << endl;       long s = 0;       for (long i = 1; i <= n; i++) {         if ((i == 1) || (a[i].k == a[i - 1].k))           s++;         else           s = 1;         b[a[i].na] = s;       }       for (long i = 1; i <= n; i++) {         cout << b[i];         if (i != n) cout <<    ;       }       cout << endl;     } else       cout << -1 << endl;   }   int main() {     init();     work();     return 0;   }   