# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp

while true
  n = gets.to_i

  break if n == 0

  arr = []
  n.times.each do
    arr << gets.to_i
  end
  arr = arr.sort
  arr.pop
  arr.shift
  puts arr.inject(0){|sum, x| sum+=x} / arr.size
end