j = gets.chomp.to_i

while j != 0 do
    g = []
    j.times do
        g.push(gets.chomp.to_i)
    end
    g.sort!.pop
    g.shift

    sum = 0
    (j - 2). times do |i|
        sum += g[i]
    end
    p sum / (j -2)
    j = gets.chomp.to_i
end
