import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) A=[int(i) for i in input().split()] E,O=[0],[0] for i in range(n): E.append(E[-1]+A[2*i]) O.append(O[-1]+A[2*i+1]) eo=E[-1] oo=O[-1] ans=oo-eo for i in range(n): ans=max(ans,oo-eo+2*E[i+1]-2*O[i+1]) print(ans)