#include <iostream>
#include <map>
#include <vector>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> input(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> input[i];
		}
		vector<int> output(n);
		int ans = 0;
		bool flag = true;
		while(flag)
		{
			flag = false;
			map<int, int> data;
			for(int i = 0; i < n; ++i)
			{
				++data[input[i]]; 
			}
			for(int i = 0; i < n; ++i)
			{
				output[i] = data[input[i]];
			}
			for(int i = 0; i < n; ++i)
			{
				if(input[i] != output[i])
				{
					flag = true;
					break;
				}
			}
			for(int i = 0; i < n; ++i)
			{
				input[i] = output[i];
			}
			++ans;
		}
		cout << ans - 1 << endl;
		for(int i = 0; i < n - 1; ++i)
		{
			cout << output[i] << " ";
		}
		cout << output[n - 1] << endl;
	}
}

int main()
{
	solve();
	return(0);
}