from collections import deque N = int(input()) V = list(map(int,input().split())) pq = deque() pq.append([0,V[0]]) if N > 1: pq.append([1,V[1]]) max = V[0] while len(pq): n = pq.popleft() for i in range(n[0]+2,N): c = n[1] + V[i] if i + 2 < N: pq.append([i,c]) else: if max < c: max = c print(max)