N = int(input()) A = list(map(int, input().split())) V = [] for i in range(0, 2 * N, 2): a = A[i] b = A[i + 1] V.append(a - b) S = sum(V) ma = S for i in range(N - 1, -1, -1): S -= 2 * V[i] ma = max(ma, S) print(ma)