#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  while(cin >> n,n) {
    vector<int> v(n);
    REP(i,n)
      cin >> v[i];
    int ans = 0;
    while(true) {
      vector<int> nextv(n);
      REP(i,n) {
        nextv[i] = count(ALL(v),v[i]);
      }
      if (v == nextv) break;
      ans++;
      v = nextv;
    }
    cout << ans << endl;
    REP(i,n) {
      if (i) cout << " ";
      cout << v[i];
    }
    cout << endl;
  }
  
}