
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = Array.init n @@ fun _ -> read_int ()

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let () =
  let n = read_int () in
  let xs = read_ints n in

  let m = (range 1 n) |> List.fold_left (fun i j ->
    if abs xs.(i) < abs xs.(j) then j else i) 0 in
  let res = Array.init (2*n) (fun _ -> (-1, -1)) in
  let len = ref 0 in

  let (l, u, s, cmp) = if xs.(m) >= 0 then (0, n-1, 1, (>)) else (n-1, 0, -1, (<)) in
  let rec func i m = 
    if cmp (i+s) u then () else (
      for_iter_ 0 2 (fun _ ->
        if cmp xs.(i) xs.(i+s) then (
          res.(!len) <- (m, i+s); len := !len + 1;
          xs.(i+s) <- xs.(i+s) + xs.(m)
      ));
      func (i+s) (if cmp xs.(i+s) xs.(m) then i+s else m)) in
  func l m;
  printf "%d\n" (!len);
  for_iter_ 0 (!len) (fun i -> let (x, y) = res.(i) in printf "%d %d\n" (x+1) (y+1))
