N = int(input()) A, B = 0, 0 AB = [] for _ in range(N-1): a, b = map(int, input().split()) AB.append((a, b)) A += a B += b if A > B: l = 0 for a, b in AB: l = max(l, b-A) ans = B-l+1 elif A < B: l = 0 for a, b in AB: l = max(l, a-B) ans = A-l+1 else: l, r = 0, 0 for a, b in AB: l = max(l, b-A) r = max(r, a-B) ans = A - max(l, r) + 1 print(ans)