n = int(input())
heights = list(map(int, input().split()))
costs = list(map(int, input().split()))

left_costs = [0] * n
right_costs = [0] * n

# Вычисляем стоимость накрытия колонн с лева
left_costs[0] = costs[0]
for i in range(1, n):
    left_costs[i] = min(left_costs[i-1] + costs[i], costs[i])

# Вычисляем стоимость накрытия колонн с права
right_costs[n-1] = costs[n-1]
for i in range(n-2, -1, -1):
    right_costs[i] = min(right_costs[i+1] + costs[i], costs[i])

# Ищем минимальную стоимость, накрывая каждую колонну
min_total_cost = float('inf')
for i in range(n):
    total_cost = left_costs[i] + right_costs[i] - costs[i]
    min_total_cost = min(min_total_cost, total_cost)

print(min_total_cost)
