#include <cstdio>
#include <map>
using namespace std;

int n;
int as[10000];
map<int, int> freq;

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    for (int i=0; i<n; i++) {
      scanf("%d", &as[i]);
    }

    int times = 0;
    while (1) {
      freq.clear();
      for (int i=0; i<n; i++) {
        freq[as[i]]++;
      }

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

      if (cnt == n) break;
      times++;
    }

    printf("%d\n", times);
    printf("%d", as[0]);
    for (int i=1; i<n; i++) {
      printf(" %d", as[i]);
    }
    puts("");
  }
}