#include <iostream>
#include <map>
using namespace std;
int num[12];
int n,cnt;
int solve(){ 

  map<int,int > mp;
  mp.clear();
  int f = 0;
  for(int i = 0 ; i < n ; i++ ){
    mp[num[i]]++; 
  }
  for(int i = 0 ; i < n ; i++ ){
    if(num[i] != mp[num[i]] )f = 1;
    num[i] = mp[num[i]];
  }

  if(f == 1){
    cnt++;
    solve();
  }
}

int main(){

  while( cin >> n,n ){

    for(int i = 0 ; i < n ; i++ ){
      cin >> num[i];
    }
    cnt = 0;
    solve();
    cout << cnt << endl;
    for(int i = 0 ; i < n ; i++ ){
      if(i == 0)cout << num[i];
      else cout <<" "<< num[i]; 
    }
    cout << endl;
  }
}