while line = gets
  sum = 0
  judges = line.to_i
  t = judges
  break if judges == 0
  a = (1..judges).map {gets.to_i}
  a.sort!
  a[judges - 1,1] = nil
  a[0,1] = nil
  while a.length != 0 do
    sum = sum + a[0]
    a[0,1] = nil
  end
  result = sum / (t - 2)
  puts result
end