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