Problem: It's Petya's birthday party and his friends have presented him a brand new "Electrician-n" construction set, which they are sure he will enjoy as he always does with weird puzzles they give him.

Construction set "Electrician-n" consists of 2n - 1 wires and 2n light bulbs. Each bulb has its own unique index that is an integer from 1 to 2n, while all wires look the same and are indistinguishable. In order to complete this construction set one has to use each of the wires to connect two distinct bulbs. We define a chain in a completed construction set as a sequence of distinct bulbs of length at least two, such that every two consecutive bulbs in this sequence are directly connected by a wire. Completed construction set configuration is said to be correct if a resulting network of bulbs and wires has a tree structure, i.e. any two distinct bulbs are the endpoints of some chain.

Petya was assembling different configurations for several days, and he noticed that sometimes some of the bulbs turn on. After a series of experiments he came up with a conclusion that bulbs indexed 2i and 2i - 1 turn on if the chain connecting them consists of exactly d_i wires. Moreover, the following important condition holds: the value of d_i is never greater than n.

Petya did his best but was not able to find a configuration that makes all bulbs to turn on, so he seeks your assistance. Please, find out a configuration that makes all bulbs shine. It is guaranteed that such configuration always exists.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the parameter of a construction set that defines the number of bulbs and the number of wires.

Next line contains n integers d_1, d_2, …, d_n (1 ≤ d_i ≤ n), where d_i stands for the number of wires the chain between bulbs 2i and 2i - 1 should consist of.

Output

Print 2n - 1 lines. The i-th of them should contain two distinct integers a_i and b_i (1 ≤ a_i, b_i ≤ 2n, a_i ≠ b_i) — indices of bulbs connected by a wire.

If there are several possible valid answer you can print any of them.

Examples

Input


3
2 2 2


Output


1 6
2 6
3 5
3 6
4 5


Input


4
2 2 2 1


Output


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


Input


6
2 2 2 2 2 2


Output


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


Input


2
1 1


Output


1 2
1 4
3 4

Note

<image> Answer for the first sample test.  <image> Answer for the second sample test. 

Solution (in JAVA):

Solution:
// package CodeForces;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;

public class Round583E {

	public static void solve() {
		int n = s.nextInt();
		int[] dis = s.nextIntArray(n);
		PriorityQueue<Pair> minHeap = new PriorityQueue<Pair>();
		for(int i = 0; i < n; i++) {
			minHeap.add(new Pair(2 * i + 1, dis[i]));
		}
		LinkedList<Integer> formTree = new LinkedList<Integer>();
		boolean chance = true; // true is put in start and false in end
		while(!minHeap.isEmpty()) {
			Pair top = minHeap.poll();
			if(chance) {
				formTree.addFirst(top.index);
			}else {
				formTree.addLast(top.index);
			}
		}
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); // index -> position
		HashMap<Integer, Integer> reverseMap = new HashMap<Integer, Integer>(); // position -> index
		int ptr = 0;
		for(Integer x : formTree) {
			map.put(x, ptr);
			reverseMap.put(ptr, x);
			ptr++;
		}
		sorterFlag = true;
		PriorityQueue<Pair> maxHeap = new PriorityQueue<Pair>();
		for(int i = 0; i < n; i++) {
			maxHeap.add(new Pair(2 * i + 1, dis[i]));
		}
		LinkedList<Edges> tree = new LinkedList<Edges>();
		int minimum = 0, maximum = n - 1;
		while(!maxHeap.isEmpty()) {
			Pair top = maxHeap.poll();
			int myPos = map.get(top.index);
			int counterPart = top.index + 1;
			// ith position -> myPos -> number of nodes before me, n - myPos - 1
			if(myPos - minimum >= top.ht - 1) {
				if(myPos - minimum == top.ht - 1) {
					int getVal = reverseMap.get(minimum);
					tree.add(new Edges(counterPart, getVal));
					minimum--;
					map.put(counterPart, minimum);
					reverseMap.put(minimum, counterPart);
				}else {
					int getVal = reverseMap.get(myPos - top.ht + 1);
					tree.add(new Edges(counterPart, getVal));
				}
			}else {
				if(maximum - myPos == top.ht - 1) {
					int getVal = reverseMap.get(maximum);
					tree.add(new Edges(counterPart, getVal));
					maximum++;
					map.put(counterPart, maximum);
					reverseMap.put(maximum, counterPart);
				}else {
					int getVal = reverseMap.get(myPos + top.ht - 1);
					tree.add(new Edges(counterPart, getVal));
				}
			}
		}
		ArrayList<Integer> converttoArray = new ArrayList<Integer>();
		for(Integer x : formTree) {
			converttoArray.add(x);
		}
		for(int i = 0; i < n - 1; i++) {
			tree.add(new Edges(converttoArray.get(i), converttoArray.get(i + 1)));
		}
		for(Edges x : tree) {
			out.println(x.u + " " + x.v);
		}
 	}
	
	public static boolean sorterFlag = false;
	
	public static class Pair implements Comparable<Pair>{
		int index;
		int ht;
		
		public Pair(int index, int ht) {
			this.index = index;
			this.ht = ht;
		}
		
		public int compareTo(Pair x) {
			if(sorterFlag) {
				if(this.ht == x.ht) {
					return x.index - this.index;
				}
				return x.ht - this.ht;
			}else {
				if(this.ht == x.ht) {
					return this.index - x.index;
				}
				return this.ht - x.ht;
			}
		}
	}
	
	public static class Edges {
		int u;
		int v;
		
		public Edges(int u, int v) {
			this.u = u;
			this.v = v;
		}
	}

	public static void main(String[] args) {
		new Thread(null, null, "Thread", 1 << 27) {
			public void run() {
				try {
					out = new PrintWriter(new BufferedOutputStream(System.out));
					s = new FastReader(System.in);
					solve();
					out.close();
				} catch (Exception e) {
					e.printStackTrace();
					System.exit(1);
				}
			}
		}.start();
	}

	public static PrintWriter out;
	public static FastReader s;

	public static class FastReader {

		private InputStream stream;
		private byte[] buf = new byte[4096];
		private int curChar, snumChars;

		public FastReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (snumChars == -1) {
				throw new InputMismatchException();
			}
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException E) {
					throw new InputMismatchException();
				}
			}
			if (snumChars <= 0) {
				return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int number = 0;
			do {
				number *= 10;
				number += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			long sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long number = 0;
			do {
				number *= 10L;
				number += (long) (c - '0');
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextLong();
			}
			return arr;
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndofLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndofLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	
}