# encodign: utf-8

f = File.open("1147in.txt", "r")
while true do
  # ????°??????§???????????? (?????????0??\???1000??\???)
  max = -1
  min = 1001
  # ????¨?????????????
  sum = 0
  # n??????
  n = f.gets.to_i
  break if n == 0 # 0?????¨????????????
  # n?????????????????????
  n.times do
    v = f.gets.to_i
    min = v if v < min
    max = v if v > max
    sum += v
  end
  sum -= (min + max)
  p sum / (n-2)
end