n = int(input()) *a, = map(int,input().split()) res = [0]*(n+1) for i in range(n): res[i] = a[2*i]-a[2*i+1] t = sum(res) for i in range(n)[::-1]: res[i] += res[i+1] ans = -1<<31 for i in range(n+1): ans = max(ans,t-2*res[i]) print(ans)