ans = []
loop do
  n   = gets.to_i
  min = 1010
  max = 0
  sum = 0

  if n == 0 then break
  else
    n.times do
      x = gets.to_i
      if min > x then min = x end
      if max < x then max = x end
      sum += x
    end
    ans << (sum - max - min) / (n - 2)
  end
end

ans.each do |a|
  puts a
end

