-- Question C Time Over

import Control.Applicative
import Control.Monad

main = do
  n <- readLn ::IO Int
  xs <- map read . words <$> getLine 
  putStr $ show ( minimum (map abs (memof xs (n-1))) )
  
sunuke1 xs = sum ( take 1 xs)
araisan1 xs = sum ( drop 1 xs)

memof xs 1 = [sunuke1 xs - araisan1 xs] 
memof xs i = memof xs (i-1) ++ [(memof xs (i-1) !! (i-2)) +2*(xs !! (i-1))] 

