#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif #include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using ull = unsigned long long; using vi =vector; using vd =vector; using vld = vector; using vs =vector; using vb =vector; using vl =vector; using vc =vector; using vtl = vector>; using vvi =vector>; using vvs =vector>; using vvc =vector>; using vvb =vector>; using vvl =vector>; using vvtl = vector; using vvvl=vector>>; using sl =stack; using pl=pair; using vpl=vector; using tl = tuple; #define rep(i,l,r)for(ll i=(l);i<(r);i++) #define YES cout<<"Yes"<void IN(T&...a){(cin>>...>>a);} templatevoid OUT(const T&... b){string c="";(cout<<...<<(cout< inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } ll input(){ ll x; cin>>x; return x; } ll ketasuu(ll n){ if(n==0) return 1; return floor(log10(abs(n)))+1; } ll gcd(ll a,ll b){ if(a==0) return b; return gcd(b%a,a); } ll lcm(ll a,ll b){ return a/gcd(a,b)*b; } ll nsqrt(ll n) { ll ok=0, ng=40000000001LL; while(ng-ok>1){ ll mid=(ok+ng)/2; if(mid<=n/mid) ok=mid; else ng=mid; } return ok; } ll vp(ll N,ll p){ ll ans=0; while(N%p==0){ ans++; N/=p; } return ans; } ll d(ll N){ ll M=nsqrt(N); ll ans=1,cnt=0; rep(i,2,M+1){ if(N%i==0){ N/=i; i--; cnt++; } else{ ans*=(cnt+1); cnt=0; } } if(N>M) ans*=2; return ans; } //N以下の素数の個数 ll pcnt(ll N){ if(N==1) return 0; else{ vl p; ll cnt=1; p.push_back(2); rep(i,3,N+1){ bool ok=true; rep(j,0,p.size()){ if(i%p[j]==0) {ok=false;break;} } if(ok==true) {p.push_back(i);cnt++;} } return cnt; } } //素因数分解 map prime_fact(ll N){ ll M = nsqrt(N); ll cnt = 0; map mp; rep(i,2,M+1){ if(N % i == 0){ cnt++; N /= i; i--; } else if(cnt != 0){ mp[i] = cnt; cnt = 0; } } if(N != 1) mp[N] = 1; return mp; } ll modpow(ll a,ll b,ll m){//a^b%m if(b==0) return 1; if(b%2==0){ ll x=modpow(a,b/2,m); return x*x%m; } ll y=modpow(a,b-1,m); return (y*(a%m))%m; } //エラトステネスの篩 vector < bool > isprime; //返り値は素数のリスト。 vector < ll > Era(int n) { isprime.resize(n, true); vector < ll > res; isprime[0] = false; isprime[1] = false; for(ll i = 2; i < n; ++i) isprime[i] = true; for(ll i = 2; i < n; ++i) { if(isprime[i]) { res.push_back(i); for(ll j = i * 2; j < n; j += i) isprime[j] = false; } } return res; } //等比級数 ll tk(ll A,ll X,ll M){//1+a+...+a^{X-1}%M if(X==1) return 1%M; if(A==1) return X%M; else{ if(X%2==0){ return (tk(A,X/2,M)*(1+modpow(A,(X/2),M)))%M; } else{ return (tk(A,X-1,M)+modpow(A,X-1,M))%M; } } } void gcin(vvl &G, ll M){ rep(i,0,M){ ll u, v; cin >> u >> v; u--; v--; G[u].emplace_back(v); G[v].emplace_back(u); } } void vcin(vl &A, ll N){ rep(i,0,N) cin >> A[i]; } bool within(ll H, ll W, ll nx, ll ny){ return (0 <= nx && nx < H && 0 <= ny && ny < W); } using mint=modint998244353; using vm=vector; using vvm=vector; using vvvm=vector; ll INF = 1e18; ll dx[8]={1,1,0,-1,-1,-1,0,1}; ll dy[8]={0,1,1,1,0,-1,-1,-1}; ll sdx[6]={-1,-1,0,0,1,1}; ll sdy[6]={-1,0,-1,1,0,1}; //cinを忘れない //変数名の重複に注意 //modは取りましたか? //変数の宣言場所 //0-indexedか1-indexedか //境界の等号 //配列の宣言(push_back前提じゃないか) //無向か有向か //型を間違えない //グリッドで縦と横を逆にしない //__int128_tのキャスト int main(void) { LL(N); vpl A(2*N); rep(i,0,2*N){ LL(a); A[i] = {a, i + 1}; } ll ans = 0; sort(A.begin(), A.end()); rep(i,0,N) ans -= A[i].first; rep(i,N+1,2*N) ans += A[i].first; cout << ans << endl; rep(i,0,N){ cout << A[i].second << " " << A[2*N-1-i].second << endl; } return 0; }