
import std.stdio, std.string, std.conv, std.algorithm;

void main() {
  for(int times; scanf("%d", &times), times != 0;) {
    int[] prev, curr = new int[](times);
    int counter = 0;
    int[int] set;
    
    foreach(i; 0..times) {
      scanf(i == times - 1 ? "%d\n" : "%d ", &curr[i]);
      set[curr[i]] = 0;
    }
    
    while(true) {
      foreach(ref i; set) i = 0;
      for(int i = 0; i < times; i++) set[curr[i]]++;
      prev = curr.dup;
      for(int i = 0; i < times; i++) curr[i] = set[curr[i]];
      if (prev != curr) {
        counter++;
        continue;
      }
      else break;
    }
    writeln(counter, "\n", curr.map!(to!string).join(" "));
  }
}