#include <iostream>
#include <algorithm>
#include <deque>
using namespace std;

int n;
int cnt;
deque<int> c;
int a[12];

void Op(deque<int> s)
{
  for (int i = 0; i < n; i++){
    c.push_back(count(s.begin(), s.end(), a[i]));
    a[i] = c.back();
  }
  cnt++;
}

int main()
{
  while (cin >> n, n){
    deque<int> s;
    int cn = 0;
    cnt = 0;

    for (int i = 0; i < n; i++){
      cin >> a[i];
      s.push_back(a[i]);
    }
    while (cn != n){
      Op(s);
	  cn = 0;
      for (int i = 0; i < n; i++){
		if (s.front() == c.front()){
          cn++;
        }
        s.pop_front();
        s.push_back(c.front());
        c.pop_front();
	  }
    }
    cout << cnt - 1 << "\n" << s[0];
    for (int i = 1; i < n; i++){
      cout << " " << s[i];
    }
    cout << endl;
  }
  
  return (0);
}