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

int main() {
  int a[12], b[13];
  int c, n;
  bool f;
  map<int, int> m;

  while (cin >> n && n) {
    m.clear();
    for (int i=0; i<n; i++) {
      cin >> a[i];
      m.insert(map<int, int>::value_type(a[i], i+1));
      a[i] = m[a[i]];
    }

    c = -1;
    do {
      f = true;
      for (int i=1; i<=n; i++) b[i]=0;
      for (int i=0; i<n; i++) b[a[i]]++;
      for (int i=0; i<n; i++) {
        if (a[i] != b[a[i]]) f=false;
        a[i] = b[a[i]];
      }
      c++;
    } while (!f);
    cout << c << endl;
    for (int i=0; i<n; i++) cout << a[i] << " ";
    cout << endl;
  }

  return 0;
}