https://www.acmicpc.net/problem/2579
n=int(input())
arr=[0]*(n+1)
num=[0]*(n+1)
for i in range(1,n+1): arr[i]=int(input())
num[1]=arr[1]
if n>1: num[2]=arr[1]+arr[2]
for i in range(3,n+1):
num[i]=max(num[i-2],num[i-3]+arr[i-1])+arr[i]
print(num[n])