Go: /*
	Problem A: ICPC 得点集計ソフトウェア
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

Python: import math
while True:
    score = []
    n = int(input())
    if n == 0:
        break
    else:
        for i in range(n):
            score.append(int(input()))
    
    score.remove(min(score))
    score.remove(max(score))
    
    print(math.floor(sum(score)/len(score)))

Python: from math import *

while True:
    a = int(input())
    if a == 0: break

    #print('a')
    score_list = []
    #max_score = 0
    #min_score = 1000
    for i in range(a):
        score_list.append(int(input()))
    #print(score_list)
    max_ = max(score_list)
    min_ = min(score_list)

    #print('b')
    ans_list = []
    flag = 0
    for score in score_list:
        if score == max_ and not flag:
            flag = 1
            continue
        else:
            ans_list.append(score)

    new_ans_list = []
    flag = 0
    for score in ans_list:
        if score == min_ and not flag:
            flag = 1
            continue
        else:
            new_ans_list.append(score)

    avg = sum(new_ans_list)/len(new_ans_list)
    print(int(avg))

Python: #!/usr/bin/python3

from math import floor

while True:
    n = eval(input())
    if n != 0:
        ls = []
        for i in range(n):
            m = eval(input())
            ls.append(m)
        ls.remove(max(ls))
        ls.remove(min(ls))
        print(floor(sum(ls)/len(ls)))
    else:
        break

Python: def calc_score(list):
    list.remove(max(list))
    list.remove(min(list))
    return int(sum(list) / len(list))

while True:
  grader = int(input())
  if grader == 0:
      break
  scores = [int(input()) for _ in range(grader)]
  print(calc_score(scores))

Python: while True:
    n=int(input())
    if n==0:
        break
    s=0
    vmin=1001
    vmax=-1
    for i in range(n):
        a=int(input())
        vmin=min(vmin,a)
        vmax=max(vmax,a)
        s+=a
    print((s-vmin-vmax)//(n-2))

Python: #(38)ICP得点集計ソフトウェア
while True:
    n=int(input())
    
    if n==0:
        break
    
    s=[int(input()) for i in range(n)]
    
    a=max(s)
    b=min(s)
    c=sum(s)
    y=(c-a-b)//(n-2)
    
    print(y)

Python: #!usr/bin/env python
# -*- coding: utf-8 -*-

while True:
        n = int(raw_input())
        if n == 0:
                break
        list = []
        for i in range(n):
                list.append(int(raw_input()))
        print (sum(list) - max(list) - min(list))/(n-2)

Python: while True:    
    n=int(input())
    if n == 0:
        break 
    else:
        A=[]
        for i in range(n):
            A.append(int(input()))
        print((sum(A)-max(A)-min(A))//(n-2))

Python: """
Problem A: ICPC 得点集計ソフトウェア
"""
if __name__ == '__main__':
    ans = []
    while(True):
        n = int(input())
        if n == 0:
            break
            
        l = [int(input()) for _ in range(n)]
        maxi = max(l)
        mini = min(l)
        ans.append((sum(l) - maxi - mini)//(n-2))
    print(*ans, sep='\n')

Python: import bisect
while True:
    n = int(input())
    if n == 0:
        break
    score = []
    for _ in range(n):
        s = int(input())
        bisect.insort(score, s)
    print(sum(score[1:-1])//(len(score)-2))

Python: # ICPC Score Totalizer Software

ans = []

while True:
    n = int(input())
    if n == 0:
        break
    point = [int(input()) for i in range(n)]
    ans.append((sum(point) - max(point) - min(point)) // (n - 2))

for i in range(len(ans)):
    print(ans[i])

Python: i = int(input())
p = 0
while i != 0:
    k =[ [0]*100]*20
    ma = 0
    mi = 1000
    for pp in range(i):
        l = int(input())
        k[p][pp] = l
        ma = max(ma,l)
        mi = min(mi,l)
    su = sum(k[p]) - ma - mi
    l = i -2
    print(su // l)
    p += 1
    i = int(input())

Python: while True:
  n = int(input())
  if n == 0:
    break
  print(sum(sorted([int(input()) for _ in range(n)])[1:-1]) // (n - 2))

Python: #!/usr/bin/python --
import sys

#2007 Domestic A
def judge(n):
  ma=0
  mi=1000
  s=0
  for i in range(0,n):
    x=int(sys.stdin.readline())
    if x<mi:
      mi=x
    if x>ma:
      ma=x
    s+=x
  print (s-ma-mi)/(n-2)

while 1:
  n=int(sys.stdin.readline())
  if n==0:
    break
  judge(n)

Python: while True:
    N=int(input())
    if(N==0): break
    s = [int(input()) for i in range(N)]
    print(sum(sorted(s)[1:-1]) // (N-2))

Python: while True:
    n = int(input())
    if n == 0:
        break
    
    a = [int(input()) for i in range(n)]
    a.sort()
    x = sum(a) - a[0] - a[-1]
    print(x // ( n- 2))

Python: while 1:
    n = int(input())
    if n == 0:
        break
    s = [int(input()) for i in range(n)]
    print((sum(s)-max(s)-min(s))//(n-2))

Python: while True:
    n=int(input())
    points=[]
    for i in range(n):
        points.append(int(input()))
    points.remove(max(points))
    points.remove(min(points))
    print(sum(points)/len(points))
    if int(input())==0:break

Python: import math
while True:
  n=int(input())
  if n==0:
    break
  else:
    S_list=[]
    for i in range(n):
      score=int(input())
      S_list.append(score)
    S_list.remove(max(S_list))
    S_list.remove(min(S_list))
    print(math.floor(sum(S_list)/len(S_list)))

Python: while True:
    n = int(input())#n=0は終わり
    s = 0
    if n==0:
        break
    else:
        b=[]
        for i in range(n):
            a = int(input())#審判の点数
            b.append((a))
        b.sort()#全員分入力してからソート
        b.pop(n-1)#listが崩れるからz-1から抜いていく
        b.pop(0)
        s=sum(b) #bのリストのI番目をたす
        ave= s/(n-2)
        print(int(ave))

Python: def main():
    while True:
        n = int(input())
        if n == 0:break
        a = []
        for i in range(n):
            a.append(int(input()))
        a.sort()
        sum = 0
        for i in range(1,n-1):sum+=a[i]
        print(sum//(n-2))


if __name__ == '__main__':
    main()

Python: while True:
    n = int(input())
    if n==0: 
        break
    l = []
    for i in range(n):
        x = int(input())
        l.append(x)
    l.sort()
    a = sum(l)-(max(l)+min(l))
    print(a//(n-2))

Python: while True:
    n=int(input())
    if n==0:
        break
    a=[]
    for i in range(n):
        a.append(int(input()))
    print((sum(a)-max(a)-min(a))//(len(a)-2))

Python: if __name__ == '__main__':
    while True:
        N = int(input())
        if N == 0:
            break

        arr = []
        for _ in range(N):
            arr.append(int(input().strip()))
        
        n = sum(arr)
        n -= max(arr) + min(arr)

        print(n // (N - 2))

Python: while True:
  n=int(input())
  if n==0:
    break
  else:
    max_s=0
    min_s=2000
    sum_s=0
    for i in range(n):
      s=int(input())
      sum_s=sum_s+s
      if s<min_s:
        min_s=s
      if s>max_s:
        max_s=s
    print((sum_s-max_s-min_s)//(n-2))

Python: while True:
    n = int(input())
    if n == 0:
        break
    x = []
    for i in range(n):
        x.append(int(input()))
    x = sorted(x)
    x.pop(0)
    x.pop(-1)
    print(sum(x) // len(x))