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

vector<int> calc(vector<int> a) {
  map<int,int> m;
  for(int i = 0; i < a.size(); ++i) {
    m[a[i]] += 1;
  }
  for(int i = 0; i < a.size(); ++i) {
    a[i] = m[a[i]];
  }
  return a;
}

int n;
vector<int> a;

int main() {
  while(cin >> n && n) {
    a.resize(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    int res = 0;
    while(1) {
      vector<int> b = calc(a);
      if(a == b) break;
      a = b;
      ++res;
    }
    cout << res << endl;
    for(int i = 0; i < n; ++i) {
      if(i) cout << " ";
      cout << a[i];
    }
    cout << endl;
  }
  return 0;
}