main = print . solve1 . map read . drop 1 . words =<< getContents

maxVal = 1000000000

solve1 :: [Integer] -> Integer
solve1 xs = solve2 xs $ drop 1 . scanl (+) 0 $ xs

solve2 _ (x:[]) = maxVal
solve2 (v:vs) (x:xs) =  min (minimum . map (abs . (-) v . flip (-) x) $ xs) (solve2 vs xs)
