n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    x, y = map(int, input().split())
    a[i] = x
    b[i] = y
p = list(map(int, input().split()))
sm = 0
mx = 0
for i in range(n):
    sm += a[i] + b[i] * (n - 1)
    mx = max(mx, sm)
print(mx)