#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

bool judge(int lineA[], int lineB[], int num)
{
	for(int i = 0; i < num; i++)
	{
		if(lineA[i] != lineB[i])
		{
			return false;
		}
	}
	return true;
}

int main()
{
	int num, lineA[16], lineB[16];
	
	while(cin >> num)
	{
		if(!num) break;
		int amo = 0;
		for(int i = 0; i < num; i++)
		{
			cin >> lineA[i];
		}
		while(1)
		{
			for(int i = 0; i < num; i++)
			{
				lineB[i] = 0;
				for(int j = 0; j < num; j++)
				{
					if(lineA[i] == lineA[j])
					{
						++lineB[i];
					}
				}
			}

			if( judge(lineA, lineB, num) ) break;
			else amo++;

			for(int i = 0; i < num; i++)
			{
				lineA[i] = 0;
				for(int j = 0; j < num; j++)
				{
					if(lineB[i] == lineB[j])
					{
						++lineA[i];
					}
				}
			}
			if( judge(lineA, lineB, num) ) break;
			else amo++;
		}
		
		cout << amo << endl;
		for(int i = 0; i < num; i++)
		{
			cout << lineA[i];
			if(i != num -1) cout << ' ';
		}
		cout << endl;
	}
}