#include<bits/stdc++.h>
using namespace std ;
int main()
{
    std::ios::sync_with_stdio(false) , cin.tie(0) ;
    int n ;
    cin >> n ;
    vector<array<int , 2>> v(n) ;
    for(int i = 0 ; i < n ; i ++)  v[i][0] = i * 2 % n , v[i][1] = (i * 2 + 1) % n ;
    for(int i = 0 ; i < n ; i ++)  cout << v[i][0] + 1 << ' ' << v[i][1] + 1 << '\n' ;
    return 0 ;
}
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
template<class T>T ABS(T x) {return x<0?-x:x;}
//int ksm(int x,int y) {int r=1;while(y) y&1?r=1ll*r*x%mod:0,x=1ll*x*x%mod,y>>=1;return r;}
//char __buf[1<<20],*__p1,*__p2;
//#define getchar() (__p1==__p2?(__p2=__buf+fread(__p1=__buf,1,1<<20,stdin),__p1==__p2?EOF:*__p1++):*__p1++)
int read() {
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
const int maxn = 4e5+10;
//const int mod = ;
//struct Edge{int to,next;}a[maxn];int h[maxn],cnt;
//void add(int x,int y) {a[++cnt]=(Edge){y,h[x]},h[x]=cnt,a[++cnt]=(Edge){x,h[y]},h[y]=cnt;}
//vector<int>G[maxn];
//void add(int x,int y) {G[x].push_back(y),G[y].push_back(x);}
int a[maxn],ans,n;
signed main() {
	n=read();
	for(int i=1;i<=n<<1;i++) a[i]=read();
	for(int i=1;i<=n<<1;i++) ans+=a[i];
	priority_queue<int,vector<int>,greater<int> >Q;
	for(int i=1;i<=n;i++) Q.push(a[n-i+1]),Q.push(a[n+i]),ans-=Q.top(),Q.pop();
	cout<<ans<<'\n';
	return 0;
}