#include <bits/stdc++.h>

#define mp       make_pair
#define mt	 make_tuple
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;
typedef    pair<long,long>    pll;

const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 100000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N;
priority_queue<pii> que;
vector<int> monster;
int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    que.push(mp(-x, 0));
  }
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    monster.push_back(x);
  }
  ll ans = INF;
  for (int start = 0; start < N; start++){
    priority_queue<pii> tmp = que;
    int cnt = 0;
    while (cnt < N){
      pii pos = tmp.top();
      tmp.pop();
      int level = monster[(start + cnt) % N] / 2;
      cnt++;
      pos.first -= level;
      pos.second--;
      tmp.push(pos);
    }
    ll res = 0;
    while (!tmp.empty()){
      pii pos = tmp.top();
      tmp.pop();
      res = max(res, (ll)-pos.second);
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
}