def compute(scores)
  minmax = scores.minmax
  total = scores.inject(:+)
  total = total - minmax[0] - minmax[1]
  puts total / (scores.size - 2)
end

while num = gets.to_i
  break if num == 0
  n = 0
  scores = []
  while n < num
    scores.push(gets.to_i)
    n += 1
  end
  compute(scores)
end