def icpc()
  while true
    judges = gets.to_i
    break if judges == 0
    a = []
    for i in 0..judges-1
      a << gets.to_i
    end
    sum = 0
    for i in 0..judges-1
      sum += a[i]
    end
    sum -= (a.max + a.min)
    puts sum/(judges-2)
  end
end

icpc()