n=int(input())
a=[0]*n
b=[0]*n
ans=0
for i in range(n):
    x,y=map(int,input().split())
    a[i],b[i]=x,y
p=list(map(int,input().split()))
cur=0
for i in range(n):
    if (b[i]<=0):
        cur+=(a[i])
    else:
        cur+=(a[i]+i*b[i])
    ans=max(ans,cur)
print(ans)