#yuki904 n=int(input()) A,B,AB=0,0,0 for i in range(n-1): a,b=map(int,input().split()) A+=a B+=b AB=max(AB,a+b) res=min(A,B)-max(0,AB-max(A,B))+1 print(res)