def main(): n=int(input()) tota=totb=M=0 for _ in range(n-1): a,b=map(int,input().split()) tota+=a totb+=b M=max(M,a+b) ans=0 for i in range(totb+1): j=i+tota-totb if j<0 or j