let rec iter a b f = if a >= b then [] else let v = f a in v :: iter (a+1) b f
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.concat [
    [|0|]; Array.init n (fun _ -> Scanf.scanf " %d" (fun v -> v)); [|0|];
  ] in
  let s =
    iter 0 (n+1) (fun i -> abs (a.(i) - a.(i+1)))
    |> List.fold_left (+) 0 in
  iter 1 (n+1) (fun i ->
    s - abs (a.(i-1)-a.(i)) - abs (a.(i)-a.(i+1)) + abs (a.(i-1)-a.(i+1)))
  |> List.iter (Printf.printf "%d\n")