#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> vec(n);

    for (auto &v : vec)
      cin >> v;

    int cnt = 0;
    while (true) {
      vector<int> stat(101, 0);
      for (auto &v : vec)
        ++stat[v];

      vector<int> vec2(n, 0);
      for (int i = 0; i < n; ++i)
        vec2[i] = stat[vec[i]];

      if (vec == vec2)
        break;
      vec = vec2;
      ++cnt;
    }

    cout << cnt << endl;
    cout << vec[0];
    for (auto itr = vec.begin() + 1; itr != vec.end(); ++itr)
      cout << " " << *itr;
    cout << endl;
  }
}
