from collections import deque N = int(input()) A = list(map(int, input().split())) ans = sum(A[0::2]) - sum(A[1::2]) tmp = ans while A: x = A.pop() - A.pop() tmp += 2 * x ans = max(ans, tmp) print(ans)