E. Egotistical Command Chain
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The ICPC is an organization made up of lots of competitive programmers, but it's very chaotic, so you have been tasked with assigning a command chain. A command chain can be seen as a directed graph where the vertex ($$$i,j$$$) indicates that the $$$i$$$-th competitive programmer can give orders to the $$$j$$$-th competitive programmer.

You know competitive programmers are very egotistical people, so they will be mad unless they have power over at least $$$a_{i}$$$ people (this number can be different for each person). But if they have control over more than $$$a_{i}$$$ persons, they will go mad with power, so you want to make the command chain so that every person has control over exactly $$$a_{i}$$$ persons. You also don't want to have a cycle, that means, a path following the edges of the graph, such that you begin and end on the same person.

We say a person $$$i$$$ has power over a person $$$j$$$ if there is a sequence of people $$$b_{1},b_{2},\ldots,b_{k}$$$ such that $$$b_{1}=i$$$, $$$b_{k}=j$$$, and $$$b_{h}$$$ can give orders to $$$b_{h+1}$$$ for all $$$1\leq h \lt k$$$. Notice that a person always has power over itself.

To save resources, and so it is not that complicated, you can use at most $$$10^{6}$$$ edges on your graph.

Input

The first line of input contains an integer $$$N$$$ ($$$1 \leq N \leq 10^{5}$$$) — The number of people in the organization.

The second line of input contains $$$N$$$ integers $$$a_{i}$$$ ($$$1 \leq a_i \leq N$$$) ($$$a_{1}+a_{2}+\ldots+a_{N}\leq 10^{6}$$$) — The $$$i$$$-th integer is the number of people that the $$$i$$$-th programmer must have power over.

Output

If it's impossible to create the command chain with the restrictions of the problem, print -1.

Otherwise, print $$$m$$$ — The number of edges in your graph. On the next $$$m$$$ lines print two integers $$$u_{i}$$$ and $$$v_{i}$$$ indicating that $$$u_{i}$$$ can give orders to $$$v_{i}$$$.

It can be proven that with the conditions of the problem, it is possible to construct the graph with at most $$$10^{6}$$$ edges.

Examples
Input
5
5 1 1 1 1
Output
4
1 2
1 3
1 4
1 5
Input
5
5 5 5 5 5
Output
-1