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