
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

//#include <atcoder/all>

//using namespace atcoder;
//typedef modint1000000007 mint;

int main(){
  int N;
  cin>>N;
  VL A(N),B(N);
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>B[i];
  ll ans=0;
  rep(i,N) ans+=B[i];
  VVL X(2,VL(N/2));
  rep(i,N) X[i%2][i/2]=A[i]-B[i];
  rep(i,2) sort(all(X[i]));
  rep(i,N/2) X[0][i]+=X[1][i];
  rep(i,N/2) if(X[0][i]>0) ans+=X[0][i];
  cout<<ans<<endl;
}

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  long long X, Y, A, B;
  
  cin >> X >> Y >> A >> B;

  long long exp = 0;
  while (1) {
    if ((double)X * A > 2e18 || X * A >= Y || X * A > X + B) {
      break;
    }
    X *= A;
    exp++;
  }
  
  long long re = ((Y - X - 1) / B);  
  exp += re;
  
  cout << exp << endl;
  
  return 0;
}