MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from collections import deque from heapq import heapify,heappush,heappop def main(): n = int(input()) tota = 0 totb = 0 for _ in range(n - 1): a,b = map(int,input().split()) tota += a totb += b ans = totb - max(totb - tota,0) + 1 print(ans) if __name__ =='__main__': main()