n = int(input()) dp = [0, 0] for v in map(int, input().split()): dp = [ max(dp[0], dp[1]), dp[0] + v ] print(max(dp))