import Debug.Trace
import Data.List
import Data.Ord

g xs
 | rs == [0] = xs !! 0
 | otherwise = xs !! (head rs + 1)
 where
  ys = zipWith (-) (tail xs) xs
  z = head $ maximumBy (comparing length) $ group $ sort ys
  rs = findIndices (/=z) ys

main = do
 n <- getLine
 when (n /= "0") $ do
  l <- getLine
  print $ g $ map read $ words l
  main