loop do
    n = gets.to_i
    break if n == 0
    input = gets.split.map(&:to_i)

    ans = (0..15).to_a.repeated_permutation(3).to_a.min_by do |s, a, c|
        count = Hash.new(0)
        noise = s
        input.each do |x|
            noise = (noise * a + c) % 256
            output = (x + noise) % 256
            count[output] += 1
        end
        count.values.map {|k| r = k.to_f / input.size; -r * Math.log(r)}.inject(:+)
    end
    puts ans * ' '
end