while true
  n = gets.to_i
  cnt = n
  sum = 0
  min = gets
  max = min
  while cnt>0
    got = gets.to_i
    min = got if min>got
    max = got if max<got
    sum += got
    cnt -= 1
  end
  puts (got-min-max)/(n-2)
  break if gets.to_i == 0
end
  