x = 0
while true
  n = gets.to_i
  if n == 0
    break
  end
  min = 1000
  max = 0
  sum = 0
  n.times{
    s = gets.to_i
    sum += s
    if s < min
      min = s
    end
    if max < s
      max = s
    end
  }
  puts (sum - min - max) / (n - 2)
end