import sys
input = sys.stdin.readline

N = int(input())
road_len = list(map(int, input().split()))
oil_cost = list(map(int, input().split()))
total_cost = 0

total_cost += (road_len[0] * oil_cost[0])
min_price = oil_cost[0]

for i in range(1, N-1):
    if min_price > oil_cost[i]:
        min_price = oil_cost[i]

    total_cost += (min_price * road_len[i])

print (total_cost)

+ Recent posts