//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;

	ll kotae = 0;
	int A[100000];
	rep(i, N) {
		cin >> A[i];
		kotae += A[i];
	}
	priority_queue<int> p, q;
	rep(i, N) {
		int b;
		cin >> b;

		if (i & 1) p.push(b - A[i]);
		else q.push(b - A[i]);
	}

	while (p.size()) {
		int a = p.top();
		int b = q.top();
		if (a + b <= 0) break;
		kotae += a + b;
		p.pop();
		q.pop();
	}

	co(kotae);

	Would you please return 0;
}
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    int N;
    cin >> N;
    int vec[N];
    for(int i=0;i<N;i++){
        cin >> vec[i];
    }
    int x,X;
    while(1){
        sort(vec,vec+N);
        x=vec[0],X=vec[N-1];
        if(vec[0]==vec[N-1]){
            cout << vec[0] << endl;
            break;
        }
        for(int i=0;i<N;i++){
            if(vec[i]%x==0)vec[i]=x;
            else vec[i]=vec[i]%x;
        }
    }    
}