#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int n;

void solve()
{
  for(int i=0;i<n;++i){
  	cout<<(2*i)%n+1<<' '<<(2*i+1)%n+1<<'\n';
  }
}

int main()
{
	cin >> n;
  	solve();
}
#include <cstdio>
#include <cstring>
#include <algorithm>
#define reg register
const int N=400002;
long long ans;
bool cmp(const int &i,const int &j) {
	return i>j;
}
struct heap{
	int h[N],n;
	void push(reg int x) {
		h[++n]=x;
		std::push_heap(h+1,h+1+n,cmp);
	}
	void pop() {
		std::pop_heap(h+1,h+1+n,cmp);
		--n;
	}
	int top() {
		return h[1];
	}
}q;
int a[N];
int R()
{
	reg int x=0; reg bool f=0; reg char ch=getchar();
	for(;ch<48||ch>57;ch=getchar()) f|=ch=='-';
	for(;ch>=48&&ch<=57;ch=getchar()) x=x*10+ch-48;
	return f?-x:x;
}
int main()
{
	reg int n=R(),i;
	for(i=1;i<=n<<1;++i) ans+=a[i]=R();
	for(i=1;i<=n;++i) q.push(a[n+i]),q.push(a[n-i+1]),ans-=q.top(),q.pop();
	printf("%lld",ans);
}