import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = map(int,read().split()) A,B = zip(*zip(m,m)) A,B SA = sum(A) SB = sum(B) low = max(SA,SB,max(a+b for a,b in zip(A,B))) high = SA + SB answer = high - low + 1 if answer < 0: answer = 0 print(answer)