Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let dp = Array.make_matrix n 2 0 in
    dp.(0).(0) <- 0;
    dp.(0).(1) <- a.(0);
    dp.(1).(0) <- 0;
    dp.(1).(1) <- max dp.(0).(1) a.(1);

    for i = 2 to n - 1 do
        if i mod 2 = 1 then (
            dp.(i).(0) <- max dp.(i - 1).(0) (dp.(i - 2).(0) + a.(i));
            dp.(i).(1) <- max dp.(i - 1).(1) (dp.(i - 2).(1) + a.(i))
        ) else (
            dp.(i).(0) <- max dp.(i - 1).(1) (dp.(i - 2).(0) + a.(i));
            dp.(i).(1) <-                     dp.(i - 2).(1) + a.(i)
        )
    done;
    Printf.printf "%d\n" dp.(n - 1).((n + 1) mod 2)
)