n=int(input()) V=list(map(int,input().split())) dp=[0]*(n+1) for i in range(n): dp[i+1]=max(dp[i],dp[i-1]+V[i]) print(dp[n])