# Here your code !
ans = 0
while ((n = gets)!=nil)
    n = n.chomp.to_i
    a = []
    next if(n == 0)
    n.times do |i|
        a[i] = (gets.to_i)
        ans += a[i]
    end
    ans -= (a.max + a.min)
    puts ans/(n - 2)
    ans = 0
end