N = int(input()) if N == 2: print(1) exit() A_sum, B_sum = 0, 0 for i in range(N - 1): A, B = map(int,input().split()) A_sum += A B_sum += B print(B_sum + 1 - max(0, B_sum - A_sum))