import Control.Monad

pops [] = [[]]
pops (x:xs) = xs : map (x:) (pops xs)
isCommonDiff (x:y:xs) = and $ zipWith (==) xs [y+z,y+z+z..]
 where z = y-x
solve xs = head [y| (y,ys)<-zip xs (pops xs), isCommonDiff ys]

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