import Control.Monad
import Data.List
import Data.Maybe
import Data.Ord
import qualified Data.ByteString.Char8 as BS

solveSub as
    | a == b && b ==c = as'
    | otherwise = sort as
    where
        as' = sortBy (comparing (\a -> (- (abs a)))) as
        a = as'!!0
        b = as'!!1
        c = as'!!2

solve [] = 0
solve an
    | a == b && b == c = 1 + solve (drop 3 an')
    | otherwise = solve (drop 3 an')
        where
            an' = if length an >= 5 then (solveSub $ take 5 an) ++ (drop 5 an) else solveSub an
            a = an'!!0
            b = an'!!1
            c = an'!!2
main = do
    n <- readLn :: IO Int
    an <- map read . words <$> getLine :: IO [Int]
    print $ (solveSub $ take 5 an) ++ (drop 5 an)
    print $ solve an