#include <bits/stdc++.h>
// #define int long long
using namespace std;
const int N = 1010;
int a[N], b[N], n, now;
signed main()
{
priority_queue<int> heap;
cin >> n;
for (int i = 1; i <= n; i ++ ) cin >> a[i];
for (int i = 1; i < n; i ++ ) cin >> b[i];
int num = 3;
for (int i = 1; i < n; i ++ )
{
heap.push(a[i]);
while (now < b[i])
{
if (num && heap.size())
{
now += heap.top(), heap.pop();
num -- ;
}
else
{
cout << -1 << endl;
return 0;
}
}
now -= b[i];
}
heap.push(a[n]);
while (num && heap.size())
{
now += heap.top(), heap.pop();
num -- ;
}
cout << now << endl;
return 0;
}