while true
  judges = gets.to_i
  break if judges == 0
  a=[]
  for i in 0..judges-1
    a<<gets.to_i
  end
  sum = 0
  min = a[0]
  max = a[0]
  for i in 0..judges-1
    sum=sum+a[i]
    if min > a[i]
      min=a[i]
    end
    if max < a[i]
      max = a[i]
    end
  end
  sum=(sum-max-min)/(judges-2)
  puts sum
end