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