Problem: Polycarp studies at the university in the group which consists of n students (including himself). All they are registrated in the social net "TheContacnt!".

Not all students are equally sociable. About each student you know the value ai — the maximum number of messages which the i-th student is agree to send per day. The student can't send messages to himself. 

In early morning Polycarp knew important news that the programming credit will be tomorrow. For this reason it is necessary to urgently inform all groupmates about this news using private messages. 

Your task is to make a plan of using private messages, so that:

  * the student i sends no more than ai messages (for all i from 1 to n); 
  * all students knew the news about the credit (initially only Polycarp knew it); 
  * the student can inform the other student only if he knows it himself. 



Let's consider that all students are numerated by distinct numbers from 1 to n, and Polycarp always has the number 1.

In that task you shouldn't minimize the number of messages, the moment of time, when all knew about credit or some other parameters. Find any way how to use private messages which satisfies requirements above. 

Input

The first line contains the positive integer n (2 ≤ n ≤ 100) — the number of students. 

The second line contains the sequence a1, a2, ..., an (0 ≤ ai ≤ 100), where ai equals to the maximum number of messages which can the i-th student agree to send. Consider that Polycarp always has the number 1.

Output

Print -1 to the first line if it is impossible to inform all students about credit. 

Otherwise, in the first line print the integer k — the number of messages which will be sent. In each of the next k lines print two distinct integers f and t, meaning that the student number f sent the message with news to the student number t. All messages should be printed in chronological order. It means that the student, who is sending the message, must already know this news. It is assumed that students can receive repeated messages with news of the credit. 

If there are several answers, it is acceptable to print any of them. 

Examples

Input

4
1 2 1 0


Output

3
1 2
2 4
2 3


Input

6
2 0 1 3 2 0


Output

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


Input

3
0 2 2


Output

-1

Note

In the first test Polycarp (the student number 1) can send the message to the student number 2, who after that can send the message to students number 3 and 4. Thus, all students knew about the credit. 

Solution (in JAVA):

Solution:
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;

/**
 * Created by Firеfly on 1/1/2017.
 */
public class Task {
    public static void main(String[] args) throws IOException {
        Emaxx emaxx = new Emaxx();
    }
}


class Emaxx {
    static char[] checker;
    FScanner fs;
    PrintWriter pw;
    long MOD = 1000000007;
    HashMap<Integer, Integer> map[];
    int[] mmas;
    int n, m;
    long[][] desk;
    long sum;
    boolean used[];
    ArrayList<Integer> list;
    HashMap<Integer, Integer>[] answer;
    int max;
    int[] hi;
    int[] sums, colors;
    int par;
    int[] parent;
    int[] temp;
    int[][] mas;
    ArrayList<BigInteger> PIQ;
    Emaxx() throws IOException {
        fs = new FScanner(new InputStreamReader(System.in));
        // pw = new PrintWriter(new FileWriter("arithnumbers.out"));
        //  fs = new FScanner(new FileReader("C:\\Users\\Firеfly\\Desktop\\New Text Document.txt"));
        //     fs = new FScanner(new FileReader("input.txt"));;
        //       pw = new PrintWriter("output.txt");
        pw = new PrintWriter(System.out); //PABOTAI, BITARD
        int n = fs.nextInt();
        PPair[] mas = new PPair[n];
        for (int i = 0; i<n; i++)
            mas[i] = new PPair(fs.nextInt(), i+1);
        Arrays.sort(mas);
        boolean used[] = new boolean[n];
        int pos = 0;
        for (int i = 0; i<n; i++)
            if (mas[i].y == 1)
                pos = i;
        used[pos] = true;
        int[][] whom = new int[n-1][2];
        rec(used, mas, pos, pos == 0? 1 : 0, whom);
        boolean can = true;
        for (int i = 0; i<n; i++)
            if (used[i] == false) {
                can = false;
            }
        if (!can)
            System.out.println(-1);
        else {
            System.out.println(n-1);
            for (int i =0 ; i<n-1; i++)
                System.out.println(whom[i][0] + " "  + whom[i][1]);
        }
        pw.close();
    }
    static int num = -1;
    int rec(boolean[] used, PPair mas[], int ind, int pos,int whom[][]) {
        while (mas[ind].x>0 && pos<used.length) {
           if (!used[pos]) {
               num++;
               mas[ind].x--;
               used[pos] = true;
               whom[num][0] = mas[ind].y;
               whom[num][1] = mas[pos].y;
             rec(used, mas, pos, pos + 1, whom);
           }
           pos++;
        }
        return num;
    }
    long recursi(ArrayList<Integer>[] mas, int num, int k, HashSet<Integer> set, HashMap<Integer, Integer> nums, long n, long cur) {
        if (k == 1) {
            if (cur * list.get(num) <= n)
                return 1;
            else return 0;
        }
        else {
            long sum = 0;
            for (int i = 0; i<mas[num].size(); i++)
                if (set.contains(mas[num].get(i))) {
                    if (cur*list.get(num)<=n)sum += recursi(mas, nums.get(mas[num].get(i)), k - 1, set, nums, n, cur*list.get(num));
                }
            return sum;
        }
    }

    int make(int[][] orig, int[] combs) {
        for (int i = 3; i<10; i++) {
            for (int j = 0; j<3; j++) {
                int curp = 0;
                int f = 0;
                int s = 1;
                int th = 2;
                if (combs[0] == 1)
                    f+=j;
                if (combs[2] == 1)
                    s+=j;
                if (combs[4] == 1)
                    th+=j;
                int f1 = 0;
                int s1 = 0;
                int th1 = 0;
                if (combs[1] == 1)
                    f1 = i-3;
                if (combs[3] == 1)
                    s1 = i-3;
                if (combs[5] == 1)
                    th1 = i-3;
                orig[i][j] = orig[f1][f] + orig[s1][s] + orig[th1][th];
            }
        }
        return orig[9][2];
    }


    double len(double x1, double x2, double y1, double y2) {
        return Math.sqrt((x2-x1)*(x2-x1)+(y1-y2)*(y1-y2));
    }

    int find(int cub, int prev) {
        if (cub == 0)
            return 1;
        int ans = 0;
        for (int i = prev+1; i<=cub; i++) {
            ans+=find(cub-i, i);
        }
        return ans;
    }
    int findNum(char[] mas) {
        int size = 1;
        int i  =0 , j = 0;
        for (i = 1,j = mas.length-1; i<=j; i++, j--)
            if ((mas[i]>='0' && mas[i]<='9') || (mas[j]>='0' && mas[j] <='9'))
                break;
            else size++;
        if (i>j)
            return -1;
        else
            return size;
    }

    int findsymb(char[] mas) {
        int size = 1;
        int i = 0, j = 0;
        for (i = 1,j = mas.length-1; i<=j; i++, j--)
            if ((mas[i]>='a' && mas[i]<='z') || (mas[j]>='a' && mas[j] <='z'))
                break;
            else size++;
        if (i>j)return -1;
        else
            return size;
    }

    int findlitts(char[] mas) {
        int size = 1;
        int i= 0, j = 0;
        for (i = 1,j = mas.length-1; i<=j; i++, j--)
            if (mas[i]=='&' || mas[i]=='*' || mas[i] == '#' || mas[j]=='*' || mas[j] =='#' || mas[j] == '&')
                break;
            else size++;
        if (i>j)
            return -1;
        else
            return size;
    }

    boolean ans(int[] second, int first[], int start) {
        int fir = 0;
        int sec = start;
        while (sec<n && first[0] != second[sec])
            sec++;
        int p = sec;
        if (sec == n) {
            return false;}
        else {
            while (sec<n && first[fir] == second[sec])
            {
                sec++;
                fir++;
            }
            if (sec!=n) {
                return false;
            }
            else {
                sec = 0;
                while (sec < p && second[sec] == first[fir]) {
                    sec++;
                    fir++;
                }
                if (sec != p)
                    return false;
                else
                    return true;
            }
        }
    }




    int gcd (int a, int b) {
        if (b == 0)
            return a;
        else
            return gcd(b, a % b);
    }



    /*

        int l1 = le[le.length-1]-46;
        int l2 = le[le.length-2]-46;
        if (l1>=l2)
            l1-=l2;
        else l1 = l1+10-l2;
        System.out.println(l1);
        long ll = dp[le.length][l1];
        int r1 = re[re.length-1]-46;
        int r2 = re[re.length-2]-46;
        if (r1>=r2)
            r1 -=r2;
        else r1 = r1+10-r2;
        long rr = dp[re.length][r1];
     */
    void PP(int[] mas) {
        System.out.println("WAT");
        ArrayList<Character> list = new ArrayList<>();
        for (int i = 0; i<mas.length; i++) {
            System.out.println(mas[i]);
            while (mas[i] > 0) {
                list.add((char) (i + 48));
                mas[i]--;
            }
        }
        Collections.sort(list);
        for (int i = list.size()-1; i>=0; i--)
            pw.print(list.get(i));
    }

    boolean good(int i, int j) {
        if ((i>=0) && (i<n) && (j>=0) && (j<m))
            return true;
        else return false;
    }

    long solve(int i, int j) {
        if (good(i, j))
        {
            if (desk[i][j]==0)
                desk[i][j] += solve(i-1, j-2)+solve(i-2, j-1)+solve(i+1, j-2)+solve(i-2, j+1);
        } else return 0;
        return desk[i][j];
    }
    boolean check(char c) {
        for (int i = 0;i<checker.length; i++)
            if (c == checker[i])
                return true;
        return false;
    }
    void make_set (int v) {
        parent[v] = v;
    }

    int find_set (int v) {
        if (v == parent[v])
            return v;
        return find_set (parent[v]);
    }

    void union_sets (int a, int b) {
        a = find_set (a);
        b = find_set (b);
        if (a != b)
            parent[b] = a;
    }

    static class IntegerUtils {
        public static long[] generateFactorials(int limit, long MOD) {
            long[] result = new long[limit];
            result[0] = 1;
            if (limit == 0) return result;
            for (int i = 1; i < limit; ++i) {
                result[i] = (result[i - 1] * i) % MOD;
            }
            return result;
        }
    }

    int[] Z_function(char[] arr) { //начинается как в начале и идёт как в начале
        int n = arr.length;
        int[] z = new int[n];
        z[0] = 0;
        for (int i = 1, l = 0, r = 0; i<n; i++) {
            if (i<=r)
                z[i] = Math.min(r-i+1, z[i-l]);
            while (i+z[i]<n && arr[i+z[i]] == arr[z[i]])
                z[i]++;
            if (i+z[i]-1>r)
            {
                l = i;
                r = i+z[i]-1;
            }
        }
        return z;
    }

    int[] prefix_function(char[] arr) { // оканчивается на этот символ
        int n = arr.length;
        int[] z = new int[n];
        for (int i = 1; i<n; i++) {
            int j = z[i-1];
            while (j>0 && arr[i] != arr[j]) {
                j=z[j-1];
            }
            if (arr[i] == arr[j]) j++;
            z[i] = j;
        }
        return z;
    }

    long substrings_string(char[] arr) {
        int p = 31;
        int n = arr.length;
        long[] pows = new long[n];
        pows[0] = 1;
        for (int i = 1; i<n; i++)
            pows[i] = pows[i-1]*p;
        long[] prefixes = new long[n];
        for (int i = 0; i<n; i++) {
            prefixes[i] = (arr[i]-'a'+1)*pows[i];
            if (i!=0) prefixes[i]+=prefixes[i-1];
        }

        long res = 0;
        for (int l = 1; l<=n; l++) {
            HashSet<Long> hh = new HashSet<>();
            for (int i = 0; i<n-l+1; i++) {
                long cur_hash = prefixes[i+l-1];
                if (i!=0) cur_hash-=prefixes[i-1];
                cur_hash *= pows[n-i-1];
                hh.add(cur_hash);
            }
            res+=hh.size();
        }
        return res;
    }

    void rabin_Karp(char[] t, char[] s) {
        int p = 31;
        long[] p_pow = new long[Math.max(t.length, s.length)];
        p_pow[0] = 1;
        for (int i = 1; i<p_pow.length; i++)
            p_pow[i] = p_pow[i-1]*p;
        long main_hash = 0;
        for (int i = 0; i<s.length; i++)
            main_hash+=(s[i]-'a'+1)*p_pow[i];
        long hashes[] = new long[t.length];
        for (int i = 0; i<t.length; i++) {
            hashes[i] = (t[i]-'a'+1)*p_pow[i];
            if (i!=0) hashes[i]+=hashes[i-1];
        }
        for (int i = 0; i+s.length-1<t.length; i++) {
            long cur_h = hashes[i+s.length-1];
            if (i!=0) cur_h-=hashes[i-1];
            if (cur_h*p_pow[i] == main_hash)
                System.out.println(i);
        }
    }

    int[] podpalindroms(ArrayList<Character> s) {
        int n = s.size();
        int[] d1 = new int[n]; //odd
        int l = 0;
        int r = -1;
        for(int i = 0; i < n; i++) {
            int k;
            if (i > r) k = 1;
            else k = Math.min(d1[l + r - i], r - i);

            while (0 <= i - k && i + k < n && s.get(i - k) == s.get(i + k)) k++;
            d1[i] = k;
            if (i + k - 1 > r) {
                r = i + k - 1;
                l = i - k + 1;
            }
        }
        int[] res = new int[n];
        for (int i = 0; i<n; i++) {
            System.out.print(d1[i] + " ");
            res[i] = d1[i];
        }
        System.out.println();
        return res;
    }



}

class FScanner {
    BufferedReader br;
    StringTokenizer st;
    FScanner(InputStreamReader isr) {
        br = new BufferedReader(isr);
    }

    FScanner(FileReader fr) {
        br = new BufferedReader(fr);
    }

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

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

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

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

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

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

}

class Gangsta  {
    int t, s, p;
    void setT(int t1) {
        t = t1;
    }
    void setS(int s1) {
        s = s1;
    }
    void setP(int p1) {
        p = p1;
    }


}

class Pair implements Comparable<Pair> {
    int x;
    boolean ready, another;
    String operation;
    String firstOp, secondOp;
    Pair(int y1) {
        x = y1;
        ready = true;
        another = false;
    }
    Pair(String firstOp1, String operation1, String secondOp1) {
        firstOp = firstOp1;
        operation = operation1;
        secondOp = secondOp1;
        ready = false;
        another = false;
    }
    Pair(String firstOp1, String operation1, String secondOp1, boolean flag) {
        firstOp = firstOp1;
        operation = operation1;
        secondOp = secondOp1;
        ready = true;
        another = true;
    }
    @Override
    public int compareTo(Pair o) {
        return Integer.compare(x, o.x);
    }
}
class PPair implements Comparable<PPair> {
    int x, y;
    PPair(int x1, int y1) {
        x = x1;
        y = y1;
    }

    @Override
    public int compareTo(PPair o) {
        return -Integer.compare(x, o.x);
    }
}