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