#include<iostream>
#include<cmath>
using namespace std;
int main(){
long n,a[13],b[13],i,j,k,m;
while(cin>>n){
if(n==0)break;
m=0;
for(i=0;i<n;i++)cin>>a[i];
for(;;){
for(i=0;i<n;i++){
for(k=0,j=0;j<n;j++)if(a[i]==a[j])k++;
b[i]=k;
}
for(i=0;i<n;i++)if(a[i]!=b[i])break;
if(i!=n)m++;else break;
for(i=0;i<n;i++)a[i]=b[i];
}
cout<<m<<endl;
cout<<b[0];
for(i=1;i<n;i++)cout<<" "<<b[i];
cout<<endl;
}
return 0;
}