loop do
    n = gets.to_i
    break if n == 0
    a = gets.split.map(&:to_i)
    (0..n).each do |i|
        b = a.dup
        b.delete_at(i)
        if b.each_cons(2).map {|x, y| y - x}.uniq.size == 1
            p a[i]
            break
        end
    end
end
