from itertools import accumulate n=int(input()) a=[*map(int,input().split())] r1=[x-y for x,y in zip(a[::2],a[1::2])] r2=list(accumulate(r1,initial=0)) print(max(r2)*2-sum(r1))