#include <iostream>
using namespace std;

int main() {
  int s[10000] = {0},c[10000] = {0},c2[10000] = {0},k,n,check=1;;
  while(cin >> n) {
    if(n==0)break;

    for(int i=0;i<n;i++) {
      cin >> s[i];
    }

    for(int i=0;i<n;i++) {
      for(int j=0;j<n;j++) {
        if(s[i] == s[j]) {
          c[i]++;
        }
      }
    }

    //ok
    k=1;
    while(check){
      check = 0;
      int c2[10000] = {0};
      for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
          if(c[i] == c[j]) {
            c2[i]++;
          }
        }
      }
      /*
        for(int l=0;l<n;l++) {
        cout << c[l] << " " << c2[l] << endl;
        }
        k++;
      */
      for(int i=0;i<n;i++) {
        if(c2[i] != c[i]) {
          for(int j=0;j<n;j++) {
            c[j] = c2[j];
          }
          check = 1;
          k++;
        }
      }

    }

    cout << k << endl;
    for(int i=0;i<n;i++) {
      cout << c[i] << " ";
    }
    cout << "\b" << endl;
  }
}