import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> breads >>= mapM_ print . solve 

solve :: [Int] -> [Int]
solve as = calcs $ 0 : as
    where
        s = visit $ 0 : as

        visit (x : y : zs) = abs (x - y) + visit (y : zs)
        visit (x : _) = abs x

        calcs (w : x : y : zs) = s + abs (w - y) - abs (w - x) - abs (x - y) : calcs (x : y : zs)
        calcs (w : x : _) = [s + abs w - abs (w - x) - abs x]

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)