### main

while true
  n = gets.strip.to_i
  break if n == 0

  pls = gets.strip.split(' ').map{|s| s.to_i}

  diffs = []
  dhash = Hash.new(0)

  for i in (1...pls.length)
    diffs[i - 1] = d = pls[i] - pls[i - 1]
    dhash[d] += 1
  end

  md = dhash.keys.max{|a, b| dhash[a] <=> dhash[b]}

  for i in (0...pls.length)
    if diffs[i] != md
      if i < pls.length - 1 && diffs[i + 1] != md
        puts pls[i + 1]
      else
        puts pls[i]
      end
      break
    end
  end
end