#include <iostream>
#include <cstring>

using namespace std;

int main(int argc, char *argv[]) {
  int *num, *hoge, n;
  num = new int[12];
  hoge = new int[12];
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++)
      cin >> num[i];

    int time = 0;
    while (true) {
      memset(hoge, 0, sizeof(int) * 12);
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
          if (num[i] == num[j])
            hoge[i]++;
      if (memcmp(num, hoge, sizeof(int) * n) == 0)
        break;
      int *tmp = hoge;
      hoge = num;
      num = tmp;
      time++;
    }

    cout << time << endl;
    for (int i = 0; i < n; i++) {
      if (i)
        cout << ' ';
      cout << num[i];
    }
    cout << endl;
  }
  return 0;
}