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)
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
cnt = 0
coins = []
for _ in range(N):
    coins.append(int(input()))

coins.reverse()
_sum = 0

for coin in coins:
    if coin > K:
        continue
    
    while True:
        _sum = _sum + coin
        cnt = cnt + 1
        if _sum > K:
            _sum = _sum - coin
            cnt = cnt -1
            break
    if _sum == K:
        print(cnt)
        break
import sys
import heapq
input = sys.stdin.readline

N = int(input())
lectures = []

for _ in range(N):
    start, end = list(map(int, input().split()))
    lectures.append([start, end])

lectures.sort(key = lambda x:x[0])
heap = []

heapq.heappush(heap, lectures[0][1])
for i in range(1, N):
    if heap[0] > lectures[i][0]:
        heapq.heappush(heap, lectures[i][1])
    else: # heap[0] <= lectures[i][0]
        heapq.heappop(heap)
        heapq.heappush(heap, lectures[i][1])

print (len(heap))

 

+ Recent posts