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:
import java.io.*;
import java.util.*;

public class Laba {
    FScanner fs;
    PrintWriter pw;
    int n, m;
    boolean[] used;
    int[][] dst;
    long[] t;
    HashMap<String, HashMap<String, Integer>> g;
    HashSet<Character> goods = new HashSet<>();

    public static void main(String[] args) throws IOException {
        new Laba().start();
    }

    public void start() throws IOException {
        fs = new FScanner(new InputStreamReader(System.in));
        // reader = new FScanner(new FileReader("input"));
        //pw = new PrintWriter("input.txt");
        pw = new PrintWriter(System.out);
        int n = fs.nextInt();
        Pair[] arr = new Pair[n];
        for (int i = 0; i < n; i++) {
            arr[i] = new Pair(i * 2, fs.nextInt());
        }
        Arrays.sort(arr, new Comparator<Pair>() {
            @Override
            public int compare(Pair pair, Pair t1) {
                return -Integer.compare(pair.y, t1.y);
            }
        });
        HashMap<Integer, Pair> map = new HashMap<>();
        ArrayList<Integer>[] placevids = new ArrayList[n * 2];
        for (int i = 0; i < n * 2; i++) {
            placevids[i] = new ArrayList<>();
        }
        int pos = 0;
        boolean even = true;
        for (int i = 0; i < n; i++) {
            if (even) {
                map.put(pos, arr[i]);
            } else {
                pos++;
                map.put(n - pos, arr[i]);
            }
            even ^= true;
        }
        for (int i = 0; i < n - 1; i++) {
            placevids[map.get(i).x].add(map.get(i + 1).x);
        }
        boolean[] used = new boolean[n];
        even = true;
        for (int i = 0; ; ) {
            int gi = even ? i : n - i - 1;
            if (used[gi])
                break;
            Pair cur = map.get(gi);
            if (cur.y == 1) {
                placevids[cur.x].add(cur.x + 1);
            } else {
                Pair rari = null;
                int qe = 0;
                boolean minus = false;
                if (map.containsKey(gi - cur.y + 1)) {
                    rari = map.get(gi - cur.y + 1);
                    minus = true;
                    qe = gi - cur.y + 1;
                } else {
                    rari = map.get(gi + cur.y - 1);
                    minus = false;
                    qe = gi + cur.y - 1;
                }
                placevids[rari.x].add(cur.x + 1);
                if (minus && !map.containsKey(qe - 1)) {
                    map.put(qe - 1, new Pair(cur.x + 1, -1));
                } else if (!minus && !map.containsKey(qe + 1)) {
                    map.put(qe + 1, new Pair(cur.x + 1, -1));
                }
            }
            used[gi] = true;
            if (!even)
                i++;
            even ^= true;
        }
        for (int i = 0; i < placevids.length; i++) {
            for (int x : placevids[i]) {
                pw.println(i + 1 + " " + (x + 1));
            }
        }
        pw.close();
    }


    void build(long a[], int v, int tl, int tr) {
        if (tl == tr)
            t[v] = a[tl];
        else {
            int tm = (tl + tr) / 2;
            build(a, v * 2, tl, tm);
            build(a, v * 2 + 1, tm + 1, tr);
            t[v] = t[v * 2] + t[v * 2 + 1];
        }
    }

    void update(int v, int tl, int tr, int pos, long new_val) {
        if (tl == tr)
            t[v] = new_val;
        else {
            int tm = (tl + tr) / 2;
            if (pos <= tm)
                update(v * 2, tl, tm, pos, new_val);
            else
                update(v * 2 + 1, tm + 1, tr, pos, new_val);
            t[v] = t[v * 2] + t[v * 2 + 1];
        }
    }

    long sum(int v, int tl, int tr, int l, int r) {
        if (l > r)
            return 0;
        if (l == tl && r == tr)
            return t[v];
        int tm = (tl + tr) / 2;
        return sum(v * 2, tl, tm, l, Math.min(r, tm))
                + sum(v * 2 + 1, tm + 1, tr, Math.max(l, tm + 1), r);
    }

    int findss(int v, int tl, int tr, long sum) {
        if (sum > t[v])
            return -1;
        if (tl == tr)
            return tl;
        int tm = (tl + tr) / 2;
        if (t[v * 2] > sum) {
            return findss(v * 2, tl, tm, sum);
        } else {
            return findss(v * 2 + 1, tm + 1, tr, sum - t[v * 2]);
        }
    }

}

class Pair {
    int x, y;

    Pair(int x1, int y1) {
        x = x1;
        y = y1;
    }
}

class FScanner {
    StringTokenizer st;
    BufferedReader reader;

    FScanner(InputStreamReader isr) throws IOException {
        reader = new BufferedReader(isr);
    }

    String nextLine() throws IOException {
        return reader.readLine();
    }

    String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String s = reader.readLine();
            if (s == null)
                return null;
            st = new StringTokenizer(s);
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    char nextChar() throws IOException {
        return (char) reader.read();
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    int[] iarr(int n) throws IOException {
        int[] mas = new int[n];
        for (int i = 0; i < n; i++)
            mas[i] = nextInt();
        return mas;
    }

    double[] darr(int n) throws IOException {
        double[] mas = new double[n];
        for (int i = 0; i < n; i++)
            mas[i] = nextDouble();
        return mas;
    }

    char[][] cmas2(int n, int m) throws IOException {
        char[][] mas = new char[n][m];
        for (int i = 0; i < n; i++)
            mas[i] = nextLine().toCharArray();
        return mas;
    }

    long[] larr(int n) throws IOException {
        long[] mas = new long[n];
        for (int i = 0; i < n; i++)
            mas[i] = nextLong();
        return mas;
    }
}