# 2次元dpだろう # dp[i個目][食べない0、1食べる]おいしさ総和最大値 N = int(input()) V = [0]+list(map(int, input().split())) dp = [[0]*2 for i in range(N+1)] for i in range(1, N+1): v = V[i] # not eating dp[i][0] = max(dp[i-1][0], dp[i-1][1]) # eating dp[i][1] = dp[i-1][0]+v ans = max(dp[N]) print(ans)