while true
  n = gets.to_i
  exit if n == 0
  a = gets.split(nil).map(&:to_i)
  s = a.inject(0){|sum, e|sum+e}
  [*0..n].each{|i|(puts a[i];break) if s-a[i] == (a[(i==0)?1:0]+a[(i==n)?n-1:n])*n/2}
end