#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

vector<int> check(int n, vector<int> v){
  vector<int> ret(n);
  REP(i, n){
    int cnt = 0;
    REP(j, n) if(v[i] == v[j]) cnt++;
    ret[i] = cnt;
  }
  return ret;
}

int main() {
  int n;
  while(cin >> n && n){
    vector<int> v(n);
    REP(i, n) cin >>v[i];
    int cnt = 0;
    vector<int> next = check(n, v);
    while(v != next){
      cnt++;
      v = next;
      next = check(n, v);
    }
    cout <<cnt <<endl;
    stringstream ss;
    ss << v[0];
    FOR(i, 1, v.size()) ss <<" " <<v[i];
    cout <<ss.str() <<endl;
  }
  return 0;
}