open Printf open Scanf
open Array

let print_array f a = Array.iter (fun v -> printf "%s " @@ f v) a; print_newline ()

let () =
  scanf " %d" @@ fun n ->
  let a = init n (fun _ -> scanf " %d" @@ fun v -> v)
  in
  let dpp = make (n+1) 0           in
  let dpn = make (n+1) (-1 lsl 60) in
  for i=1 to n-1 do
    dpp.(i) <- max
      (dpp.(i-1) + a.(i-1))
      (dpn.(i-1) - a.(i-1));
    dpn.(i) <- max
      (dpp.(i-1) - a.(i-1))
      (dpn.(i-1) + a.(i-1));
  done;
  dpp.(n) <- dpp.(n-1) + a.(n-1);
  dpn.(n) <- dpn.(n-1) - a.(n-1);
  (* print_array string_of_int dpp;
  print_array string_of_int dpn; *)
  print_int @@ max dpp.(n) dpn.(n)

