Problem:
Score : 600 points

Problem Statement

Snuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}.

He can perform the following operation any number of times:

Operation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y.

He would like to perform this operation between 0 and 2N times (inclusive) so that a satisfies the condition below. Show one such sequence of operations.
It can be proved that such a sequence of operations always exists under the constraints in this problem.

Condition: a_1 \leq a_2 \leq ... \leq a_{N}

Constraints

2 \leq N \leq 50

-10^{6} \leq a_i \leq 10^{6}

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_{N}

Output

Let m be the number of operations in your solution. In the first line, print m.
In the i-th of the subsequent m lines, print the numbers x and y chosen in the i-th operation, with a space in between.
The output will be considered correct if m is between 0 and 2N (inclusive) and a satisfies the condition after the m operations.

Sample Input 1

3
-2 5 -1

Sample Output 1

2
2 3
3 3

After the first operation, a = (-2,5,4).

After the second operation, a = (-2,5,8), and the condition is now satisfied.

Sample Input 2

2
-1 -3

Sample Output 2

1
2 1

After the first operation, a = (-4,-3) and the condition is now satisfied.

Sample Input 3

5
0 0 0 0 0

Sample Output 3

0

The condition is satisfied already in the beginning.

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {

    let n = read_t_in_line::<i32>()[0];
    let mut aa = read_t_in_line::<i32>();
    // 負の数と正の数で、それぞれ絶対値が最大のものをもとめる
    // 絶対値が大きいほうを見つけたら、その数値自分以外のすべての要素に加算していく
    // こうすることですべての数が正 or 負にできる
    // その後は一番大きい(正) or 小さい(負)の数字を一番左 or 右に足しこんで、
    // その後は順番に足しこんでいけばできあがり
    
    const INF : i32 = 1 << 30;

    let mut min_neg = INF;
    let mut max_pos = -INF;
    let mut min_idx = 0;
    let mut max_idx = 0;

    let mut ops : Vec<(i32, i32)> = vec![]; // (from, to)
    
    for i in 0..n {
        let a = aa[i as usize];
        if a < 0 && min_neg > a {
            min_neg = a;
            min_idx = i;
        }
        if a >= 0 && max_pos < a {
            max_pos = a;
            max_idx = i;
        }
    }

    let mut is_only_pos = true;

    if max_pos == -INF {
        // only neg
        is_only_pos = false;
    }
    else if min_neg == INF {
        // only pos
    }
    else if max_pos.abs() < min_neg.abs() {
        // apply neg
        for i in 0..n {
            ops.push((min_idx, i));
        }
        // only neg
        is_only_pos = false;

    }
    else{
        // apply pos
        for i in 0..n {
            aa[i as usize] += aa[max_idx as usize];
            ops.push((max_idx, i));
        }
        // only pos
    }

    if is_only_pos {
        ops.push((max_idx, 0));
        for i in 0..n-1 {
            ops.push((0, i + 1));
        }
    }
    else {
        ops.push((min_idx, n - 1));
        for i in (1..n).rev() {
            ops.push((n - 1, i - 1));
        }
    }

    println!("{}", ops.len());
    for (from, to) in ops {
        println!("{} {}", from + 1, to + 1);
    }
    

}