VK Cup 2017 - Qualification 1
B
News About Credit
Codeforces
1200
原题
← AC →
翻译中…

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 $*a*_{*i*}$ — 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 $*a*_{*i*}$ 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 $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($0 ≤ *a*_{*i*} ≤ 100$), where $*a*_{*i*}$ 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.

翻译中…

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.

翻译中…

样例

Input #1
4
1 2 1 0
Output #1
3
1 2
2 4
2 3
InputCopy OutputCopy
Input #2
6
2 0 1 3 2 0
Output #2
6
1 3
3 4
1 2
4 5
5 6
4 6
InputCopy OutputCopy
Input #3
3
0 2 2
Output #3
-1
InputCopy OutputCopy
题目信息
题号
769B
时间限制
1 s
内存限制
256 MB
标签
*special
贪心
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。