const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
const lines = input.trim().split("\n").map(Number)
while (lines.length > 1) {
    let idx = lines.shift()
    let i = 0
    let point = []
    while (i < idx) {
        point.push(lines.shift())
        i++
    }
    point.sort((a,b) =>  a - b)
    point.shift()
    point.pop()
    const sum = point.reduce((sum, value) => sum + value, 0)
    console.log(Math.floor(sum/(idx - 2)))
}
