# 区間dpだと間に合わない、左右からの累積和で解ける # 左からのネット得点累積和、右からのネット得点累積和 # どこまで左、どこまで右なら最大値となるか N = int(input()) A = list(map(int, input().split())) from_left = [] for i in range(N): calc = A[i*2]-A[i*2+1] from_left.append(calc) from_left_cumu = [0] temp = 0 for i in range(N): temp += from_left[i] from_left_cumu.append(temp) #print(from_left) #print(from_left_cumu) from_right = [] for i in range(N): calc = A[N*2-i*2-1]-A[N*2-i*2-2] from_right.append(calc) from_right_cumu = [0] temp = 0 for i in range(N): temp += from_right[i] from_right_cumu.append(temp) from_right_cumu.reverse() #print(from_right) #print(from_right_cumu) ans = -10**20 for i in range(N+1): ans = max(ans, from_left_cumu[i]+from_right_cumu[i]) print(ans)