#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define INF 1000000001 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (a); i >= (b); i--) using namespace std; typedef long long ll; typedef pair pii; const double PI = acos(-1.0); int N; int A[1501], B[1501]; int main() { ios::sync_with_stdio(false); cin >> N; FOR(i,0,N) cin >> A[i]; FOR(i,0,N) cin >> B[i]; FOR(i,0,N) B[i] /= 2; int ans=INF; FOR(st,0,N) { priority_queue< pair > heap; FOR(i,0,N) heap.push(pii (-A[i], 0)); FOR(i,0,N) { int e = (st+i) % N; pii p = heap.top(); heap.pop(); heap.push(pii(p.first-B[i], p.second-1)); } int t = 0; while (!heap.empty()) { pii p = heap.top(); heap.pop(); t = max(t, -p.second); } ans = min(ans, t); } cout << ans << endl; return 0; }