#include using namespace std; typedef pair M; typedef priority_queue, greater > P; int sol(P pq, int s, int n, const int* b) { int ans = 0, idx; for (int i = 0; i < n; i++) { idx = (i + s) % n; M x = pq.top(); pq.pop(); x.first += b[idx] / 2; x.second++; pq.push(x); } while (!pq.empty()) { M x = pq.top(); pq.pop(); ans = max(ans, x.second); } return ans; } int main(){ int n, tmp, b[1500], ans; cin >> n; P pq; for(int i = 0; i < n; i++) { cin >> tmp; pq.push(make_pair(tmp, 0)); } for(int i = 0; i < n; i++) { cin >> b[i]; } ans = n; for(int i = 0; i < n; i++) { ans = min(ans, sol(pq, i, n, b)); } cout << ans << "\n"; return 0; }