N = int(input()) V = list(map(int,input().split())) def vsum(i,v): vlist = [0]*N while i < N: if i < 2: vlist[i] = V[i] elif i < 3: vlist[i] = vlist[i-2] + V[i] elif i < N: vlist[i] = max(vlist[i-2],vlist[i-3])+V[i] i += 1 return vlist[N-1] print(vsum(0,0))