#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

//typedef pair<int,int> pp;
const int MAXN = 13;

vector<int> hindo(vector<int> s)
{
    map<int, int> m;
    REP(s.size()) m[s[i]]++;

    vector<int> ans;
    REP(s.size()) ans.push_back(m[s[i]]);
    
    return ans;
}
void os(vector<int> s)
{
    REP(s.size())
    {
        cout << s[i];
        if(i == s.size() -1){ cout << endl; return;}
        cout << " ";
    }
    return ;
}

int main()
{
    int n;
    while(cin >> n && n)
    {
        int num;
        vector<int> s[MAXN + 1];

        REP(n) {cin >> num; s[0].push_back(num);}

        REP(MAXN) s[i+1] = hindo(s[i]);

        REP(MAXN)if(s[i+1] == s[i] ){cout << i << endl; break;}
        os( s[MAXN -1]);
    }
    return 0;
}