import Data.List

main = interact $ unlines . map (show . icpc_score) . read' . lines
 where
  read' ("0":_) = []
  read' (n:xs) = let (xs1,xs2) = splitAt (read n) xs in map read xs1 : read' xs2

icpc_score ns = ((`div` (length ns - 2)) . sum . init . tail . sort) ns