import copy N = int(input()) A = [] B = [] for i in range(N-1): a,b = map(int,input().split()) A.append(a) B.append(b) ma = max(sum(A),sum(B)) amarib = 0 D = copy.deepcopy(A) for i in range(len(A)): b = B[i] for j in reversed(range(len(A))): if i==j: continue temp = min(D[j],b) b-=temp D[j]-=temp amarib += b amaria = 0 D = copy.deepcopy(B) for i in range(len(A)): a = A[i] for j in reversed(range(len(A))): if i==j: continue temp = min(D[j],a) a-=temp D[j]-=temp amaria += a print(ma-max(amaria,amarib)+1)