Trees Transplanting
题号:NC15734
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
Special Judge, 64bit IO Format: %lld

题目描述

It’s universally acknowledged that there’re innumerable trees in the campus of HUST.

 

You’ve found N forests under the management of a strange-tempered ranger. He told you that the i-th forest consisted of ai trees, and you can transplant these trees between any two forests i and j in such a strange rule: if and only if ai<=aj, then you could transplant ai trees from the forest j to the forest i. Now you want to know if you could make it that only two forests remain non-empty at last  after some operations.

 
You don't need to find the quickest way, instead, output any of the solution. If there’s no solution or the minimum number of steps is more than 108, printing -1 is enough.

输入描述:

The first line contains a integer N, the number of forests.
The next line are N integers following, indicating the initial number of trees in each forest, a1, a2, a3, ... ,an,.

输出描述:

In the first line you output an integer K, the number of steps in your solution.
Then K lines follow, in each line are two integers i and j, indicating a movement from the forest i to the forest j.
示例1

输入

复制
4
1 2 1 4

输出

复制
2
3 1
2 1