#include<iostream>
#include<map>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

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

int main() {
  for (int N; cin >> N && N; ) {
      vector<int> a(N);
      REP(i, N) cin >> a[i];

      int ans = 0;
      map<int, int> count;
      for (;;) {
          count.clear();
          REP(i, N) ++count[a[i]];
          vector<int> b(N);
          REP(i, N) b[i] = count[a[i]];

          if (a == b) break;
          ans++;
          a = b;
      }
      cout << ans << endl;
      cout << a[0];
      for (int i = 1; i < N; i++) cout << " " << a[i]; cout << endl;

  }
  return 0;
}