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

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

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