program both_sides_merger
  implicit none
  integer :: n, i, j, k, x, w(1000)
  integer(8) :: a(1000), odd, evn, m
  w = 0
  a = 0_8
  odd = 0_8
  evn = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    if (a(i).gt.0_8) then
      if (mod(i,2).eq.1) then
        odd = odd+a(i)
      else
        evn = evn+a(i)
      end if
    end if
  end do
  if (odd.eq.0_8.and.evn.eq.0_8) then
    j = maxloc(a(1:n),1)
    write(*,'(i0)') a(j)
    write(*,'(i0)') n-1
    do i = n, j+1, -1
      write(*,'(i0)') i
    end do
    do i = 1, j-1
      write(*,'(i0)') 1
    end do
    stop
  end if
  write(*,'(i0)') max(odd,evn)
  k = n
  x = 0
  if (evn.gt.odd) then
    a(1:k-1) = a(2:k)
    k = k-1
    x = x+1
    w(x) = 1
  end if
  do while (k.gt.1)
    if (k.eq.2) then
      k = k-1
      x = x+1
      w(x) = 2
      cycle
    end if
    if (a(1).lt.0_8) then
      a(1:k-2) = a(3:k)
      k = k-2
      x = x+2
      w(x-1:x) = 1
      cycle
    end if
    if (a(3).ge.0_8) then
      a(3) = a(1)+a(3)
      a(1:k-2) = a(3:k)
      k = k-2
      x = x+1
      w(x) = 2
      cycle
    end if
    if (k.eq.3) then
      k = k-1
      x = x+1
      w(x) = 3
      cycle
    end if
    a(4) = a(2)+a(4)
    a(2:k-2) = a(4:k)
    k = k-2
    x = x+1
    w(x) = 3
  end do
  write(*,'(i0)') x
  do i = 1, x
    write(*,'(i0)') w(i)
  end do
  stop
end program both_sides_merger