import itertools n=int(input()) A=list(map(int,input().split())) ah=[] for i in range(n): ah.append(A[2*i]-A[2*i+1]) ac=[0]+list(itertools.accumulate(ah)) ans=0 for i in range(n+1): ans=max(ans,-ac[-1]+ac[i]*2) print(ans)