main = do
  getLine
  as <- map read . words <$> getLine
  let s = sum as
  let results = points s . diffs $ as
  print . minimum . center $ results

diffs [] = []
diffs (x:xs) = x : [ x + y | y <- diffs xs ]

point s x = abs (2 * x - s)

points s xs = [ point s x | x <- xs]

center = init . tail
