program non_decreasing
  implicit none
  integer :: n, a(50), mn, mx, i, k, b(100,2), in, ix, c(50)
  a = 0
  b = 0
  c = 0
  read(*,*) n
  read(*,*) a(1:n)
  mn = 1000000
  in = -1
  mx = -1000000
  ix = -1
  do i = 1, n
    if (mn.ge.a(i)) then
      mn = a(i)
      in = i
    end if
    if (mx.le.a(i)) then
      mx = a(i)
      ix = i
    end if
  end do
  k = 0
  if (mn.ge.0) then
    do i = 1, n-1
      do while (a(i).gt.a(i+1))
        k = k + 1
        b(k,1) = ix
        b(k,2) = i+1
        a(i+1) = a(i+1) + mx
      end do
      if (a(i+1).gt.mx) then
        mx = a(i+1)
        ix = i+1
      end if
    end do
    write(*,'(i0)') k
    if (k.eq.0) stop
    do i = 1, k
      write(*,'(i0,x,i0)') b(i,1), b(i,2)
    end do
    stop
  end if
  if (mx.le.0) then
    do i = n, 2, -1
      do while (a(i-1).gt.a(i))
        k = k + 1
        b(k,1) = in
        b(k,2) = i-1
        a(i-1) = a(i-1) + mn
      end do
      if (a(i-1).lt.mn) then
        mn = a(i-1)
        in = i-1
      end if
    end do
    write(*,'(i0)') k
    if (k.eq.0) stop
    do i = 1, k
      write(*,'(i0,x,i0)') b(i,1), b(i,2)
    end do
    stop
  end if
  c = a
  do i = 1, n-1
    do while (a(i).gt.a(i+1))
      k = k + 1
      if (k.gt.2*n) exit
      b(k,1) = ix
      b(k,2) = i+1
      a(i+1) = a(i+1) + mx
    end do
    if (k.gt.2*n) exit
    if (a(i+1).gt.mx) then
      mx = a(i+1)
      ix = i+1
    end if
  end do
  if (k.le.2*n) then
    write(*,'(i0)') k
    if (k.eq.0) stop
    do i = 1, k
      write(*,'(i0,x,i0)') b(i,1), b(i,2)
    end do
    stop
  end if
  a = c
  k = 0
  b = 0
  do i = n, 2, -1
    do while (a(i-1).gt.a(i))
      k = k + 1
      b(k,1) = in
      b(k,2) = i-1
      a(i-1) = a(i-1) + mn
    end do
    if (a(i-1).lt.mn) then
      mn = a(i-1)
      in = i-1
    end if
  end do
  write(*,'(i0)') k
  if (k.eq.0) stop
  do i = 1, k
    write(*,'(i0,x,i0)') b(i,1), b(i,2)
  end do
  stop
end program non_decreasing