n = gets.to_i
l = n.times.map{ gets.to_i }
dp = [Array.new(n, 0)] + [l.rotate(-1)]
(1...n).each do |i|
  n.times do |j|
    k = ((n-i)+j-1)%n
    if i % 2 == 1
      if l[j] < l[k] then dp[0][j] = [dp[0][j], dp[1][j]].max
      else dp[0][(j+1)%n] = [dp[0][(j+1)%n], dp[1][j]].max
      end
    else
      dp[1][j] = [dp[1][j], dp[0][j]+l[k]].max
      dp[1][(j+1)%n] = [dp[1][(j+1)%n], dp[0][j]+l[j]].max
    end
  end
end
p dp[n%2].max