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