#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#define Maxn 1000008 
using namespace std;
typedef long long ll;

int n;
ll d;
ll son[Maxn];
map <ll,ll> M;

struct node{
	ll num;
	ll val;
}N[Maxn];

bool cmp(node a,node b){	return a.val > b.val;}

int main()
{
	memset(son,0,sizeof(son));
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++)
	{
		scanf("%lld",&d);
		M[d] = i;
		N[i].num = i,N[i].val = d;
	}
	sort(N+1,N+1+n,cmp);
	map<ll,ll>::iterator iter;;
	for(int i = 1;i < n;i ++)
	{
		ll u = N[i].num;
		if((N[i].val - n + 2 + (son[u] << 1)) < N[n].val) continue;
		iter = M.find(N[i].val - n + 2 + (son[u] << 1));
		if(iter == M.end()) continue;
		ll v = iter->second;
		son[v] += son[u]+1;
		printf("%lld %lld\n",u,v);
	}
	return 0;
}