#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++ )

int main(){
  int N;
  while(cin >> N , N){
    int cnt = 0;
    vector<int> data(N);
    rep(i,N) cin >> data[i];
    while("homo"){
      vector<int> now = data;
      rep(i,N) now[i] = count(data.begin(),data.end(),data[i]);
      if(now == data) break;
      data = now;
      cnt++;
    }
    cout << cnt << endl;
    rep(i,N) cout << (i?" ":"") << data[i];
    cout << endl;
  }
}