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