#include #include #include #include #include using namespace std; #define REP(i,s,e) for (i = s; i <= e; i++) #define rep(i,n) REP (i,0,(int)(n)-1) #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP (i,(int)(n)-1,0) #define INF (int)1e8 #define MOD (int)(1e9+7) typedef long long ll; int main(void) { int i, n; int a[1500], b[1500]; cin >> n; rep (i,n) cin >> a[i]; rep (i,n) cin >> b[i]; int s, ans = INF; rep (s,n) { int count = 0; priority_queue> q; // (-level,-count) rep (i,n) q.push(make_pair(-a[i],0)); rep (i,n) { auto p = q.top(); q.pop(); p.first -= b[(s+i)%n]/2; p.second--; count = max(count,-p.second); q.push(p); } ans = min(count,ans); } cout << ans << endl; return 0; }