//g++ -std=c++11 -O2 -Wall microwave.cpp -o microwave
#include <bits/stdc++.h>
using namespace std;
//Globals
//Funks
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
//COMMENCE CODE
int n;
cin >> n;
usleep(1000000);
int ranges [n];
for(int r = 0; r < n; r++)
{
cin >> ranges[r];
}
long priceToGetHere [n];
priceToGetHere[0] = 0;
priceToGetHere[n] = -1;
int prices [n];
for(int r = 1; r < n; r++)
{
cin >> prices[r];
priceToGetHere[r] = -1;
}
//Input collected, lets do stuff
int curPos = 0;
prices[0] = 0;
int setEnd = 0;
int maxrange;
long adj;
while(priceToGetHere[n] != priceToGetHere[curPos])
{
maxrange = min(ranges[curPos], n - curPos);
adj = priceToGetHere[curPos] + prices[curPos];
if(adj < priceToGetHere[curPos+1] || priceToGetHere[curPos+1] == -1)
{
for(int r = 1; r <= maxrange; r++)
{
priceToGetHere[curPos + r] = adj;
}
setEnd = maxrange;
}
else if(setEnd < maxrange)
{
for(int r = setEnd + 1; r <= maxrange; r++) //!
{
if(adj < priceToGetHere[curPos + r] || priceToGetHere[curPos+r] == -1)
{
while(r <= maxrange)
{
priceToGetHere[curPos + r] = adj;
r++;
}
break;
}
}
}
if(setEnd != 0)
{
setEnd--;
}
curPos++;
}
cout << priceToGetHere[n];
}