N = int(input()) V = list(map(int,input().split())) #dp[i][0]:V_iをとらない #dp[i][1]:V_iをとる dp = [[0 for __ in range(2)] for _ in range(N)] dp[0][0] = 0 dp[0][1] = V[0] dp[1][0] = V[0] dp[1][1] = V[1] for i in range(2,N): dp[i][0] = max(dp[i-1][1],dp[i-2][1]) dp[i][1] = max(dp[i-2][1]+V[i],dp[i-1][0]+V[i]) print(max(dp[N-1][0],dp[N-1][1]))