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