def one_str(): return input() def many_int(): return list(map(int, input().split())) input_count = 0 N = many_int()[0] A = many_int() dp = [0]*N dp[0] = A[0] for i in range(1, N): dp[i] = max(dp[i-2]+A[i], dp[i-1]) print(dp[N-1])