if __name__ == '__main__':
n = int(input())
q = []
for i in range(n):
w,s = map(int,input().split())
q.append([w+s,w,s])
q.sort()
res = -float('inf')
sum = 0
for i in range(n):
res = max(res,sum - q[i][2])
sum += q[i][1]
print(res)