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