Problem: You are given a sequence D_1, D_2, ..., D_N of length N. The values of D_i are all distinct. Does a tree with N vertices that satisfies the following conditions exist?

* The vertices are numbered 1,2,..., N.
* The edges are numbered 1,2,..., N-1, and Edge i connects Vertex u_i and v_i.
* For each vertex i, the sum of the distances from i to the other vertices is D_i, assuming that the length of each edge is 1.



If such a tree exists, construct one such tree.

Constraints

* 2 \leq N \leq 100000
* 1 \leq D_i \leq 10^{12}
* D_i are all distinct.

Input

Input is given from Standard Input in the following format:


N
D_1
D_2
:
D_N


Output

If a tree with n vertices that satisfies the conditions does not exist, print `-1`.

If a tree with n vertices that satisfies the conditions exist, print n-1 lines. The i-th line should contain u_i and v_i with a space in between. If there are multiple trees that satisfy the conditions, any such tree will be accepted.

Examples

Input

7
10
15
13
18
11
14
19


Output

1 2
1 3
1 5
3 4
5 6
6 7


Input

2
1
2


Output

-1


Input

15
57
62
47
45
42
74
90
75
54
50
66
63
77
87
51


Output

1 10
1 11
2 8
2 15
3 5
3 9
4 5
4 10
5 15
6 12
6 14
7 13
9 12
11 13

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;
public class Main{
	static LinkedList<Integer>[]adj;
	static int[]sub;
	static long[]sumD,originD;
	static boolean[]v;
	static boolean yes;
	static void dfs(int i,int par) {
		v[i]=true;
		for(int j:adj[i]) {
			if(j==par)continue;
			dfs(j, i);
			sumD[i]+=(sumD[j]+sub[j]);
		}
	}
	static void dfs2(int i,int par) {
		for(int j:adj[i]) {
			if(j==par)continue;
			rerooting(i, j);
			yes&=(originD[j]==sumD[j]);
			dfs2(j, i);
			rerooting(j, i);
		}
	}
	static void rerooting(int from,int to) {
		int oldSubFrom=sub[from];
		int oldSubTo=sub[to];
		int newSubFrom=oldSubFrom-oldSubTo;
		int newSubTo=oldSubTo+newSubFrom;
		long newSumDFrom=sumD[from]-(sumD[to]+oldSubTo);
		long newSumDTo=sumD[to]+newSumDFrom+newSubFrom;
		sub[from]=newSubFrom;
		sub[to]=newSubTo;
		sumD[from]=newSumDFrom;
		sumD[to]=newSumDTo;
	}
	static void main() throws Exception{
		int n=sc.nextInt();
		long[][]in=new long[n][];
		originD=new long[n];
		HashMap<Long, Integer>map=new HashMap<>();
		for(int i=0;i<n;i++) {
			in[i]=new long[] {sc.nextLong(),i};
			originD[i]=in[i][0];
			map.put(in[i][0], i);
		}
		Arrays.sort(in,(x,y)->Long.compare(y[0], x[0]));
		sub=new int[n];
		sumD=new long[n];
		Arrays.fill(sub, 1);
		StringBuilder ans=new StringBuilder();
		adj=new LinkedList[n];
		for(int i=0;i<n;i++)adj[i]=new LinkedList<>();
		for(int i=0;i<n-1;i++) {
			long D=in[i][0];int idx=(int)in[i][1];
			long parD=D-(n-sub[idx]-1)+sub[idx]-1;
			if(parD==D || !map.containsKey(parD)) {
				pw.println(-1);
				return;
			}
			int par=map.get(parD);
			sub[par]+=sub[idx];
			ans.append((idx+1)+" "+(par+1)+'\n');
			adj[idx].add(par);
			adj[par].add(idx);
		}
		v=new boolean[n];
		int root=(int)in[n-1][1];
		dfs(root, -1);
		for(boolean i:v) {
			if(!i) {
				pw.println(-1);
				return;
			}
		}
		yes=sumD[root]==originD[root];
		dfs2(root, -1);
		if(!yes) {
			pw.println(-1);
			return;
		}
		pw.println(ans);
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}