def solve(ab): sa = sum(a for a,b in ab) sb = sum(b for a,b in ab) min_b0 = max(max(a+b for a,b in ab) - sb, 0) return sb-max(0, min_b0-sa+sb)+1 n = int(input()) ab = [tuple(map(int,input().split())) for _ in range(n-1)] print(solve(ab))