#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define Swap(a,b) (a+=b,b=a-b,a-=b)
static inline long Max(long a,long b){return a>b?a:b;}
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline void DescRadix32(int *a,const int sz,const int minus)
{
  int x,shift=0,elem[0400],temp[sz];
  while(shift<040)
  {
    int bucket[0400]={0};
    rep(i,sz){x=(a[i]>>shift)&0377;bucket[x]++;temp[i]=a[i];}
    elem[0]=0;rep(i,0377)elem[i+1]=elem[i]+bucket[i];
    rep(i,sz){x=(temp[i]>>shift)&0377;a[elem[x]]=temp[i];elem[x]++;}
    shift+=010;
  }
  rep(i,minus>>1)Swap(a[sz-minus+i],a[sz-1-i]);
  rep(i,(sz-minus)>>1)Swap(a[i],a[sz-minus-1-i]);
}
int main(void)
{
  int N=IN(),A[N],B=0,m1=0,m2=0,p1[N/2],p2[N/2];long score=0;
  rep(i,N){A[i]=IN(),score+=A[i];}
  rep(i,N){B=IN();if(i&1){p1[i/2]=B-A[i];if(B-A[i]<0)m1++;}else{p2[i/2]=B-A[i];if(B-A[i]<0)m2++;}}
  DescRadix32(p1,N/2,m1);DescRadix32(p2,N/2,m2);
  rep(i,N>>1){if(p1[i]+p2[i]>0)score+=p1[i]+p2[i];else break;}
  return OUT(score),0;
}
#include <bits/stdc++.h>
#define debug(x) cout << ##x << ":\t" << (x) << endl;
using namespace std;
#define ll long long
const int N = 2e6 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
int n;
ll a[N], b[N];
ll ans;
priority_queue<ll>q[2];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)scanf("%lld", &a[i]), ans += a[i];
	for (int i = 1; i <= n; i++)scanf("%lld", &b[i]);
	for (int i = 1; i <= n; i++) {
		q[i & 1].push(b[i] - a[i]);
	}
	while (1) {
		if (!q[0].empty() && q[0].top() + q[1].top() > 0) {
			ans += q[0].top() + q[1].top();
			q[0].pop();
			q[1].pop();
		}
		else break;
	}
	printf("%lld\n", ans);
	return 0;
}