let () = Scanf.scanf "%d\n" @@ fun l ->
  let as_ = Array.init l @@ fun _ -> Scanf.scanf "%d\n" @@ fun a -> a in
  let ans, dp1, dp2, dp3 =
    Array.fold_left (fun (ans, dp1, dp2, dp3) a ->
      max ans (max dp1 (max dp2 dp3)),
      (if a < 2 then 0 else a - a mod 2 + dp1),
      (if a < 1 then 0 else a - (a + 1) mod 2 + max dp1 dp2),
      (if a < 2 then 0 else a - a mod 2 + max dp2 dp3))
    (min_int, 0, 0, 0) as_ in
  Printf.printf "%d\n" @@ Array.fold_left ( + ) (( ~- ) @@ max ans @@ max dp1 @@ max dp2 dp3) as_

