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