#include <iostream>
using namespace std;

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int n;

void solve() {
  int b[20], a[20], res = 0;
  rep(i,n) cin>>b[i];
  while (true) {
    rep(j,n) {
      int cnt = 0;
      rep (k,n) if (b[j] == b[k]) cnt++;
      a[j] = cnt;
    }
    
    bool flag = false;
    rep(j,n) if (b[j] != a[j]) flag = true;
    if (!flag) break;
    
    rep(j,n) b[j] = a[j];
    res++;
  }
  cout<<res<<endl<<a[0];
  REP(i,1,n) cout<<" "<<a[i];
  cout<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}