N=int(input()) A=[int(s) for s in 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])