program select_half
  implicit none
  integer(8), parameter :: infty = lshift(1_8, 61)
  integer :: n, i, j
  integer(8) :: a(200000) = 0, dp(0:200000, 2) = -infty
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    do j = (i + 1) / 2, n / 2 - (n - i + 1) / 2, -1
      dp(j, 1) = maxval(dp(j, :))
      if (j > 0) then
        dp(j, 2) = merge(a(i), dp(j - 1, 1) + a(i), dp(j - 1, 1) == -infty)
      end if
    end do
  end do
  write(*,'(i0)') maxval(dp(n / 2, :))
end program select_half