from sys import stdin, stdout input = lambda: stdin.readline().rstrip() println = stdout.write def main(): N = int(input()) V = list(map(int, input().split())) val = [0, 0] + V dp = [0] * (N + 2) for i in range(2, N + 2): dp[i] = max(dp[i-1], dp[i-2] + val[i]) print(dp[-1]) main()