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

dp1 = [0] * n
dp1[0] = costs[0]

for i in range(1, n):
    if heights[i] >= heights[i-1]:
        dp1[i] = min(dp1[i-1] + costs[i], dp1[i-1])
    else:
        dp1[i] = min(dp1[i-1] + costs[i], dp1[i-1] + (heights[i-1] - heights[i]) * 2)

result = dp1[n-1]
print(result)