N=int(input()) A=list(map(int,input().split())) B=[0]+[a-b for a,b in zip(A[::2],A[1::2])] for i in range(N): B[i+1]+=B[i] print(max(B)*2-B[-1])