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()))
for i in range(1,n+1):
    ans+=(a[i-1]+i*b[i-1])
print(ans)