#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#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()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  while(cin>>n, n){
    int arr[2][n];
    int *next = arr[1], *prev = arr[0];
    int cnt = -1;
    REP(i,n) cin>>arr[0][i];
    do{
      cnt++;
      REP(i,n) next[i] = (int)count(prev, prev+n, prev[i]);
      swap(prev, next);
    }while(memcmp(prev, next, sizeof(int) * n) != 0);
    printf("%d\n",cnt);
    REP(i,n) printf("%d%c",prev[i],i==n-1?'\n':' ');
  }
  return 0;
}