

import sys
n = int(input()) # 도시의 개수
road = list(map(int, input().split())) # 도로의 길이
cost = list(map(int, input().split())) # 주유소의 리터 당 가격
result = 0
first_cost = cost[0]
for i in range(n-1):
if cost[i] < first_cost:
first_cost = cost[i]
result += first_cost*road[i]
print(result)
for문에서 n-1로 한 이유는 마지막 도시에서의 기름값은 의미가 없기 때문이다.
다음번 도시에 넣을 기름 가격이 첫 번째 도시에서 넣은 기름의 가격보다 작을 경우, 결과갑을 해당값으로 업데이트 해준다.