Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in

    let rec loop i m mi =
        if i = n then mi else
            if abs a.(i) > abs m then loop (i + 1) a.(i) i
                                 else loop (i + 1) m mi
    in
    let mi = loop 0 0 0 in
    let m = a.(mi) in
    let adjust = Array.fold_left (fun acc v -> if v * m < 0 then acc + 1 else acc) 0 a in
    Printf.printf "%d\n" (adjust + n - 1);
    Array.iteri (fun i v ->
        if v * m < 0 then Printf.printf "%d %d\n" (mi + 1) (i + 1)) a;
    if m > 0 then for i = 0 to n - 2     do Printf.printf "%d %d\n" i (i + 1) done
             else for i = n - 1 downto 1 do Printf.printf "%d %d\n" i (i - 1) done

)