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