n = gets.strip.to_i v = gets.strip.split(' ').map(&:to_i) total = [0, 0] (0..v.length-1).each do |i| total[0], total[1] = total[1] + v[i], [total[0], total[1]].max end p total.max