pairs (x:y:xs) = scanl (\(_, b) c -> (b, c)) (x, y) xs
pairs _ = []
total l = sum $ (abs.uncurry (-)) <$> pairs (0:l++[0])
skips [] = []
skips (x:xs) = xs : fmap (x:) (skips xs)
skipTotal t (x:y:z:xs) | (x-y)*(y-z) >= 0 = t : skipTotal t (y:z:xs)
                       | otherwise = t - abs (x-y) - abs (y-z) + abs (x-z) : skipTotal t (y:z:xs)
skipTotal t _ = []

main = do
  _ <- getLine
  l <- fmap read.words<$>getLine
  mapM_ putStrLn $ show <$> skipTotal (total l) (0:l++[0])
