#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    vector<int> ary;
    int tmp;
    REP(i,n){
      cin>>tmp;
      ary.push_back(tmp);
    }
    int countt = 0;
    while(true){
      vector<int> ary2;
      REP(i,n){
        ary2.push_back(count(ary.begin(),ary.end(),ary[i]));
      }
      if(ary==ary2){
        cout<<countt<<endl;
        bool f = false;
        REP(i,n){
          if(f) cout<<" ";
          f = true;
          cout<<ary[i];
        }
        cout<<endl;
        break;
      }
      ary = ary2;
      countt++;
    }
  }
  return 0;
}