#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    int ans = 0;
    while (true) {
      int cnt[110] = {};
      vector<int> ns(n);
      for (int i = 0; i < n; i++) {
        cnt[s[i]]++;
      }
      for (int i = 0; i < n; i++) {
        ns[i] = cnt[s[i]];
      }
      if (s == ns) break;
      ans++;
      swap(s, ns);
    }
    cout << ans << endl;
    for (int i = 0; i < n; i++) {
      cout << s[i] << " \n"[i + 1 == n];
    }
  }

  return 0;
}
