local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local mfl, mce = math.floor, math.ceil
local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
if n % 2 == 0 then
  local hn = brs(n, 1)
  local p1, p2 = {t[1]}, {t[2]}
  for i = 2, hn do
    p1[i] = p1[i - 1] + t[2 * i - 1]
    p2[i] = p2[i - 1] + t[2 * i]
  end
  local ret = mma(p1[hn], p2[hn])
  for i = 1, hn - 1 do
    local cand = p1[i] + p2[hn] - p2[i]
    ret = mma(ret, cand)
  end
  if ret < 100000000000000 then
    print(ret)
  else
    print("100000000000000")
  end
else
  -- use0, nouse0, use1, nouse1, use2, nouse2
  local dp = {t[1], false, false, 0, false, false}
  for i = 2, n do
    local dst = {false, false, false, false, false, false}
    if dp[1] then
      dst[2] = dp[1]
    end
    if dp[2] then
      dst[1] = dp[2] + t[i]
      dst[4] = dp[2]
    end
    if dp[3] then
      if dst[4] then
        dst[4] = mma(dst[4], dp[3])
      else
        dst[4] = dp[3]
      end
    end
    if dp[4] then
      dst[3] = dp[4] + t[i]
      dst[6] = dp[4]
    end
    if dp[5] then
      if dst[6] then
        dst[6] = mma(dst[6], dp[5])
      else
        dst[6] = dp[5]
      end
    end
    if dp[6] then
      dst[5] = dp[6] + t[i]
    end
    for j = 1, 6 do
      dp[j] = dst[j]
      -- io.write(tostring(dp[j]))
      -- io.write(j == 6 and "\n" or " ")
    end
  end
  if not dp[5] then
    print(dp[6])
  elseif not dp[6] then
    print(dp[5])
  else
    print(mma(dp[5], dp[6]))
  end
end
