#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;
int main(){   
	int n,c;  
	int r=0;   
	while(cin >> n && n){      
		c = 0;       
		vector<int> one(n);
		vector<int> two(n);    
		for(int i=0;i<n;i++){ 
			cin >> one[i];      
		}        
		while(one != two){           
			for(int k=0;k<one.size();k++){      
				r=0;            
				for(int i=0;i<one.size();i++)if(one[k]==one[i])r++;     
				two[k]=r;            
			}          
			c++;      
			swap(one,two);    
		}         
		cout << c-1 << endl;       
		for(int i=0;i<n;i++){     
			if(i)cout << " ";     
			cout << one[i];       
		}       
		cout << endl; 
	}
}