import Control.Monad
import Data.List

main :: IO ()
main = readLn >>= main'
    where
        main' n
            | n == 0 = return ()
            | otherwise = replicateM n readLn >>= print . solve n . sort >> main

solve :: Int -> [Int] -> Int
solve n = (`div` (n - 2)) . sum . tail . init 
