n = gets.to_i A = [0] + gets.split.map(&:to_i) d = Array.new(n + 1) { [0] * 2 } d[0][0] = 0 d[0][1] = -Float::INFINITY for i in (1..n) d[i][0] = [d[i - 1][0], d[i - 1][1]].max d[i][1] = d[i - 1][0] + A[i] end ans = d[n].max puts ans