main :: IO ()
main = do
  _ <- getLine
  a <- reads2List :: IO [Int]
  print $ solve a

solve :: [Int] -> Int
solve a = minimum $ fmap (\n -> abs (2 * n - la')) (init a') where
  a' = scanl1 (+) a
  la' = last a'


s2List :: Read a => String -> [a]
s2List = fmap read . words

reads2List :: Read a => IO [a]
reads2List = do
  s <- getLine
  return (s2List s)
