#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define st(it) sort(it.begin(),it.end())
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
#define pb(v,e) v.push_back(e)
#define ms(a,v) memset(a,v,sizeof(a))
#define cp(a,b,n) rep(i,n)a[i] = b[i]
#define print_array_int(a,n) rep(i,n-1){printf("%d ",a[i]);}printf("%d\n",a[n-1])

string sint(int i){
   stringstream buf;
   buf<<i;
   return buf.str();
}

/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/

int n;
int ant[15],ata[15];

bool check(){
   rep(i,n){
      if(ant[i] != ata[i])return false;
   }
   return true;
}

int main(){
   while(scanf("%d",&n) != EOF, n){
      rep(i,n){
         scanf("%d",&ant[i]);
      }
      int times = 0;
      ms(ata,0);
      map<int,int> tt;
      while( times<5 ){
         tt.clear();
         times++;
         rep(i,n){
            tt[ant[i]]++;
         }

         rep(i,n){
            ata[i] = tt[ant[i]];
         }

         if( check()){
            break;
         }
         cp(ant,ata,n);
      }

      printf("%d\n",times-1);
      print_array_int(ant,n);
   }
   return 0;
}