let memoize n f =
  let dp = Hashtbl.create n in
  let rec get x =
    try Hashtbl.find dp x with
    | Not_found ->
        let result = f get x in
        Hashtbl.add dp x result;
        result in
  get

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let dp = memoize (4 * n) @@ fun dp (i, n, b) ->
    if (i + 1) / 2 < n then -12345678901234567 else
    match (i, n, b) with
    | (_, 0, true) -> 0
    | (0, _, _) -> -12345678901234567
    | (i, n, false) -> as_.(i - 1) + dp (i - 1, n - 1, true)
    | (i, n, true) -> max (dp (i - 1, n, true)) (dp (i - 1, n, false)) in
  Printf.printf "%d\n" @@ max (dp (n, n / 2, true)) (dp (n, n / 2, false))
