object Main{
  def main(args: Array[String]): Unit = {
    var n = readInt
    while(n>0){
      var scores = List.empty[Int]
      for(i<- 0 until n){
        scores = readInt :: scores
      }
      val s = scores.sum - scores.min - scores.max
      println(s/(n-2))
      n = readInt
    }
  }
}