N = gets.to_i V = gets.split.map(&:to_i) ans = V.inject([0,0]) do |dp, v| [dp.max, dp[0] + v] end puts ans.max