module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = unlines . map show

solver (n:as) =
  if oddn > evnn then (oddn:length oddorder:oddorder)
                 else (evnn:length evnorder:evnorder)
  where
    (oddn, oddorder) = deleting as id
    (evnn, evnorder) = deleting (tail as) (1:)


deleting :: [Int] -> ([Int]->[Int]) -> (Int, [Int])
deleting (a1:[]) order = (a1, (order []))
deleting (a1:a2:[]) order = deleting [a1] (order . (2:))
deleting (a1:a2:a3:[]) order
  | a1 < 0 && a1 < a3 = deleting [a3] (order . (1:) . (1:))
  | a3 < 0 && a3 < a1 = deleting [a1] (order . (3:) . (2:))
  | True              = deleting [a1+a3] (order . (2:))
deleting (a1:a2:a3:a4:as) order
  | a1 < 0 = deleting (a3:a4:as) (order . (1:) . (1:))
  | a3 < 0 = deleting (a1:(a2+a4):as) (order . (3:))
  | True   = deleting ((a1+a3):a4:as) (order . (2:))

