#!/usr/bin/ruby --

#2007 Domestic A
def judge(n)
  ma=0
  mi=1000
  s=0
  n.times do |i|
    x=gets.to_i
    if(x<mi) then mi=x end
    if(x>ma) then ma=x end
    s+=x
  end
  puts (s-ma-mi)/(n-2)
end

while(true)
  n=gets.to_i
  if(n==0) then break end
  judge(n)
end