#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 1e5 + 100;
int a[N], b[N], n, ev[N], od[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    long long ans = 0;
    int odd = 0, even = 0;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    for (int i = 1; i <= n; i++) {
        if (i & 1) od[++odd] = a[i] - b[i];
        else ev[++even] = a[i] - b[i];
        ans += b[i];
    }
    sort(ev + 1, ev + even + 1);
    reverse(ev + 1, ev + even + 1);
    sort(od + 1, od + odd + 1);
    reverse(od + 1, od + odd + 1);
    int i = 1, j = 1;
    while (i <= odd && j <= even && od[i] + ev[j] > 0) {
        ans += od[i] + ev[j];
        i++, j++;
    }
    cout << ans << endl;
}
#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 AscRadix32(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]);
  rep(i,sz>>1)Swap(a[i],a[sz-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++;}}
  AscRadix32(p1,N/2,m1);AscRadix32(p2,N/2,m2);
  rep(i,N>>1)if(p1[(N>>1)-1-i]+p2[(N>>1)-1-i]>0)score+=p1[(N>>1)-1-i]+p2[(N>>1)-1-i];
  return OUT(score),0;
}