n = int(input())
distance = list(map(int, input().split()))
price = list(map(int, input().split()))
total = 0
small = price[0]
for i in range(0, n-1): # 마지막 가격은 필요없는 값이니까 n-1까지만 돌아도 상관없음
if price[i] < small:
small = price[i]
total = total + distance[i] * small
print(total)
