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

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

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

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

		score_list := []int{}
		for i := 0; i < n; 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))
	}
}

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

Python: while True :
    num = int(input())
    if num == 0 :
        break
    A = []
    for i in range(num):
        sco = int(input())
        A.append(sco)
        A.sort()
    del A[num - 1]
    del A[0]

    B = int(sum(A)/(num-2))
    print(B)

Python: import math
while True:
    n=int(input())
    if n==0:
        break
    l=[]
    for i in range(n):
        l.append(int(input()))
    slist=sorted(l)
    del slist[0]
    del slist[n-2]
    x=sum(slist)/len(slist)
    print(math.floor(x))

Python: while True:
    judges = int(input())
    if not judges:
        break
    a = [int(input()) for i in range(judges)]
    a.remove(max(a))
    a.remove(min(a))
    print(int(sum(a) / len(a)))

Python: # -*- coding: utf-8 -*-

def main():
    while 1:
        n = int(input())
        if n == 0:
            return 0
        s_l = []
        for _ in range(n):
            s_l.append(int(input()))
        ans = int((sum(s_l) - max(s_l) - min(s_l))/(n-2))
        print(ans)

if __name__ == "__main__":
    main()

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

Python: # coding: utf-8
while True:
    n = int(input())
    if n == 0:
        break
    t = 0
    ma = 0
    mi = 1000
    for i in range(n):
        s = int(input())
        t += s
        if(s > ma):
            ma = s
        if(s < mi):
            mi = s
    print((t - ma - mi) // (n - 2))

Python: import sys
while 1:
    n=int(input())
    if n==0:
        sys.exit()
    l=[0]*n
    ma=0
    mi=1000
    s=0
    for i in range(n):
        l[i]=int(input())
        s+=l[i]
        if l[i]>ma:
            ma=l[i]
        if l[i]<mi:
            mi=l[i]
        
    print ((s-ma-mi)//(n-2))

Python: while True:
    n=int(input())
    if n<3:
        break
    lst=[int(input()) for i in range(n)]
    a=sum(lst)
    b=min(lst)
    c=max(lst)
    avg=(a-b-c)//(n-2)
    print(avg)

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

    ma = 0
    mi = 1000
    s = 0

    for i in range(n):
        x = int(raw_input())
        if ma < x:
            ma = x
        elif mi > x:
            mi = x
        s += x
    print (s - ma - mi) / (n - 2)

Python: # coding: utf-8
# Your code here!
while True:
    n=int(input())
    
    x=[]
    for i in range(n):
        s=int(input())
        x.append(s)
    
    x1=sorted(x)
    if n==0:
        break
    else:
        sum1=sum(x1)
        sum1-=x1[0]+x1[n-1]
        y=sum1//(n-2)
        
        print(y)

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

Python: j = 0
lists = []
flag = 0
cnt = 0
while 1:
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        s = int(input())
        lists.append(s)
    for i in range(n):
        if lists[i] == max(lists):
            flag += 1
            pass
        elif lists[i] == min(lists):
            flag += 1
            pass
        else:
            cnt += lists[i]
    if flag >= 2:
        n -= 2
    print(cnt // n)

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

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

    x = 0
    b = -1
    c = 1001
    for i in range(n):
        a = int(input())
        x += a
        b = max(b, a)
        c = min(a, c)
        y = (x-b-c)//(n-2)
        
    i += 1

    print(y)

Python: while 1:
    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: while 1:
    n = int(input())
    if n==0:
        break
    lst = []
    for i in range(n):
        lst.append(int(input()))
    lst.sort()
    del lst[0]
    del lst[n-2]
    y=sum(lst)
    print(y//(n-2))

Python: while True:
    n=int(input())
    min=1000
    max=0
    sum=0
    if n==0:
        break
    for i in range(n):
        tennsuu=int(input())
        sum+=tennsuu
        if tennsuu<min:
            min=tennsuu
        if tennsuu>max:
            max=tennsuu
    print((sum-min-max)//(n-2))

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: N = int(input())
while N != 0:
        total = 0
        minimam = 1000
        maximam = 0
        for _ in range(N):
                s = int(input())
                total += s
                minimam = min(minimam, s)
                maximam = max(maximam, s)
        print(int((total-minimam-maximam)/(N-2)))
        N = int(input())

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: 
while True:
    n=int(input())
    m,smin,smax=0,1000,-1
    if n==0:break
    for i in range(n):
        s=int(input())
        smin=min(smin,s)
        smax=max(smax,s)
        m += s
    print((m-smin-smax)//(n-2))

Python: a=int(input())
while a!=0:
    M=0
    m=1000
    sam=0
    for i in range(a):
        b=int(input())
        sam+=b
        M=max(M,b)
        m=min(m,b)
    print(int((sam-M-m)/(a-2)))
    a=int(input())

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: a=[]
i=0
while True:
    
    N=int(input())
    if N==0:
        break
    else:
        for i in range(N):
            n=int(input())
            a.append(n)
        a.sort()
        a.pop()     
        a.pop(0)    
        print(sum(a) // len(a))
        a.clear()

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

    ma = 0
    mi = 1000
    s = 0

    for i in range(n):
        x = int(raw_input())
        if ma < x:
            ma = x
        elif mi > x:
            mi = x
        s += x
    print ((s - ma - mi) // (n - 2))

Python: import math
import copy

def average(points):
    sum = 0
    for i in points:
        sum += i
    return sum / len(points)

outputs = []

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

    points = []
    for _ in range(num):
        point = int(input())
        points.append(point)

    points = sorted(points)
    points = points[1:len(points)-1]

    ave = average(points)
    outputs.append(int(ave))

for ave in outputs:
    print(ave)

Python: # coding: utf-8
# 38
while True: 
    n = int(input())
    S = []
    if n==0:
        break
    for i in range(n):
        S.append(int(input()))
    #print(S)
    S.sort()
    #print(S)
    S.pop(0)
    S.pop()
    #print(S)

    print(sum(S)//(n-2))