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

bool same(int n, int *array, int *rs)
{
  int cnt = 0;

  for (int i = 0; i < n; i++){
    if (array[i] == rs[i]){
      cnt++;
    }
  }

  return (n == cnt ? true : false);
}

int main()
{
  int n;
  int array[12];

  while (scanf("%d", &n), n){
    for (int i = 0; i < n; i++){
      scanf("%d", &array[i]);
    }
    for (int op = 0;; op++){
      int rs[12];
      for (int i = 0; i < n; i++){
        int cnt = 0;
        for (int j = 0; j < n; j++){
          if (array[i] == array[j]){
            cnt++;
          }
        }
        rs[i] = cnt;
      }
      if (same(n, array, rs)){
        printf("%d\n", op);
        for (int i = 0; i < n - 1; i++){
          printf("%d ", rs[i]);
        }
        printf("%d\n", rs[n - 1]);
        break;
      }
      memcpy(array, rs, sizeof(array));
    }
  }

  return (0);
}