#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
#define FOR(i, n) for(int (i) = 0; (i) < (n); (i)++)
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u){
    stringstream ss;
    ss << t;
    ss >> u;
}

int main(){
	int n;
	while(cin >> n && n){
		vector<int> seq(n, 0);
		map<int, int> tb;
		int c = 0;
		FOR(i, n) cin >> seq[i];
		while(1){
			vector<int> seq2(n, 0);
			bool f = true;

			FOR(i, n) tb[seq[i]]++;

			FOR(i, n){
				seq2[i] = tb[seq[i]];
				if(seq2[i]!=seq[i]) f = false;
			}

			if(f){
				cout << c << endl;
				FOR(i, n){
					if(i) cout << " ";
					cout << seq[i];
				}
				cout << endl;
				break;
			}else{
				seq = seq2;
				map<int, int>().swap(tb);
				c++;
			}
		}
	}
	return 0;
}