let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let arr = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let arr = Array.append arr [|0|] in
  let a_l = Array.to_list arr in

  let cum f init l =
    let rec aux prev res = function
      | [] -> res
      | hd :: tl -> 
        let acc = f prev hd in
        aux hd (acc::res) tl
    in
    aux init [] l
  in

  let l = cum (fun x y -> abs (y-x)) 0 a_l in
  let ans = List.fold_left (+) 0 l in

  let rec aux res = function
    | [] -> res
    | hd1 :: hd2 :: hd3 :: tl -> 
      let acc = abs (hd3-hd1) - (abs (hd3-hd2) + abs(hd2-hd1)) in
      aux (acc::res) (hd2::hd3::tl)
    | _ -> res
  in

  let l = aux [] (0::a_l) in
  let l = List.rev l in
  List.iter (fun x -> Printf.printf "%d\n" @@ ans+x) l;
