N=int(input()) PV=map(int,input().split()) n0,n1=0,0 for v in PV: n0,n1=max(n0,n1),n0+v print(max(n0,n1))