object Main {
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.toInt)
        for (n <- in if n != 0) {
            var max = 0
            var min = 1000
            var sum = 0
            for (m <- in.take(n)) {
                max = m max max
                min = m min min
                sum += m
            }
            println((sum - max - min) / (n - 2))
        }
    }
}