Go: package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		num := nextInt(sc)
		if num == 0 {
			break
		}

		score_list := []int{}
		for i := 0; i < num; i++ {
			score_list = append(score_list, nextInt(sc))
		}
		// 得点リストをソートした後、最低点と最高点を取り除く(3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1 : len(score_list)-1]
		// 得点リストの得点を合計し、スライスの個数で割って平均点を出す
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

Python: while True:
    N = int(input())
    if N == 0:
        break
    S = []
    for _ in range(N):
        S.append(int(input()))
    S.sort()
    S = S[1:N-1]
    ans = sum(S)//len(S)
    print(ans)

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

Python: while 1:
    score = []
    n = int(input())
    if n == 0:
        break
    for _ in range(n):
        score.append(int(input()))
    score.sort()
    del score[0]
    del score[-1]
    print(sum(score)//len(score))

Python: while True :
    N = int(input())
    if N == 0 :
        break
    data = list(int(input()) for i in range(N))
    
    data.sort()
    del data[0]
    del data[-1]
    
    data_ave = sum(data)/len(data)
    print(int(data_ave))

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))//(n-2))

Python: def solve(n):
    a = [int(input()) for i in range(n)]
    print((sum(a)-max(a)-min(a))//(n-2))


while(True):
    n = int(input())
    if(n == 0):
        quit()
    solve(n)

Python: while True:
    n = int(input())
    if n == 0:
        break

    s = [int(input()) for i in range(n)]
    s.sort()
    score = sum(s) - s[0] - s[-1]
    print(score // (n - 2))

Python: while 1:
    n = int(input())
    if n == 0:
        break

    pt = []
    for _ in range(n):
        pt.append(int(input()))

    pt.sort()
    pt.pop(0)
    pt.pop()

    ans = int(sum(pt) / len(pt))
    print(ans)

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

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

Python: while True:
    n=int(input())

    if n==0:
        break
    a=[]
    for i in range(n):
        a=a+[int(input())]
    sum=0
    for i in range(n):
        sum+=a[i]

    score=int((sum-max(a)-min(a))/(n-2))
    print(score)

Python: while True:
    n=int(input())
    if n==0:
        break
    i,min,max,a=0,1000,0,0
    while i<n:
        s=int(input())
        a+=s
        if min>s:
            min=s
        if max<s:
            max=s
        i+=1
    print((a-min-max)//(n-2))

Python: a=100

Python: while(True):
  n = int(input())
  if n == 0:
    quit()
  a = []
  for i in range(n):
    a.append(int(input()))
  a.sort()
  a = a[1:-1]
  ans = 0
  for j in a:
    ans += j
  print(ans//len(a))

Python: while True:
    n=int(input())
    if n==0:
        break

    s=[int(input()) for i in range(n)]
    print((sum(s)-min(s)-max(s))//(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: import statistics

while True:
    n = int(input())
    if n == 0: break
    s = [int(input()) for i in range(n)]
    ave = statistics.mean(s[1:-1])
    print(int(ave))

Python: while True:
    n=int(input())
    if n==0:
        break
    else:
        A=[]
        i=1
        while i <=n:
            a=int(input())
            A.append(a)
            i=i+1
        b=(sum(A)-max(A)-min(A))//(n-2)
        print(b)

Python: import math

def main():
    r = []
    while True:
        n = int(input())
        if n == 0:
            break
        m = []
        for i in range(n):
            m.append(int(input()))
        r.append(math.floor((sum(m) - max(m) - min(m))/(n-2)))
    for j in r:
        print(j)

main()

Python: while True:
    n = int(input())
    if n == 0:
        break
    judges = []

    for i in range(n):
        judges.append(int(input()))

    print((sum(judges) - max(judges) - min(judges)) // (len(judges) - 2))

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

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

Python: import math
for i in range(30):
    n = int(input())
    if n == 0:
        break
    else:
        ls = []
        for i in range(n):
            ls.append(int(input()))
        ls.sort()
        ls.remove(ls[0])
        ls.remove(ls[-1])
        print(math.floor(sum(ls)/len(ls)))

Python: str=readlines()
print(str)

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

Python: while True:
	n = int(input())
	if n == 0: break
	s, vmin, vmax = 0, 1001, -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: ans = []
while True:
    N = int(input())
    if N == 0:
        break
    
    A = sorted([int(input()) for i in range(N)])
    ans.append(sum(A[1:-1]) // (N - 2))
        
[print(i) for i in ans]

Python: while True:
    #審判の数
    n = int(input())
    if n == 0:
        break
    a = [0]*n               #空いてる配列
    for i in range(n):       #空いてる配列に点数を入れる
        s = int(input())
        a[i] = s
    tensu = (sum(a) - min(a) -max(a))/(len(a)-2) #一番でかい点数と一番小さい点数は一つずつ引いて平均
    print(int(tensu))        #平均点！

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

Python: while True:
    n=int(input())
    if n==0:break
    a=0
    mi=1145141919
    ma=0
    for i in range(n):
        t=int(input())
        mi=min(mi,t)
        ma=max(ma,t)
        a+=t
    a-=mi+ma
    print(a//(n-2))

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

Python: while True:
    n = int(input())
    if n == 0:
        break
    MIN = 1000
    MAX = 0
    points = 0
    for i in range(n):
        p = int(input())
        if MIN > p:
            MIN = p
        if MAX < p:
            MAX = p
        points += p
    print((points - MIN - MAX) // (n - 2))