#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int a[13];
	int n;
	while(cin >> n && n)
	{
		memset(a,0,sizeof(a));
		vector<int> res;
		rep(i,n) 
		{
			cin >> a[i];
			res.push_back(a[i]);
		}
		
		int count = 0;
		while(true)
		{
			map<int,int> m;

			rep(i,n)
			{
				m[a[i]]++;
			}

			rep(i,n)
			{
				a[i] = m[a[i]];
			}

			bool flag = true;
			rep(i,n)
			{
				if(res[i] != a[i])
				{
					flag = false;
				}
			}

			if(flag)
			{
				cout << count << endl;
				rep(i,n)
				{
					if(i == n-1) cout << a[i] << endl;
					else cout << a[i] << " ";
				}
				break;
			}
			else
			{
				rep(i,n)
				{
					res[i] = a[i];
				}
				count++;
			}
		}
	}
	return 0;
}