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: while True:
    n=int(input())
    if n==0:exit()
    l=[ int(input()) for i in range(n) ]
    print(int((sum(l)-max(l)-min(l))/(n-2)))

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

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

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

Python: averages = []

while True:
    amount = int(input())
    if amount == 0:
        break
    scores = [int(input()) for i in range(amount)]
    scores.remove(max(scores))
    scores.remove(min(scores))
    averages.append(sum(scores) // amount)

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

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<3:break
    print((sum(sorted([int(input()) for _ in [0]*n])[1:-1]))//(n-2))

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

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

Python: p=1
num=[]
while p==1:
    x=int(input())
    if x==0:
        break
    else:
        y=x
        while y>0:
            a=int(input())
            num.append(a)
            y-=1
        num.sort()
        del num[0]
        del num[-1]
        poo=sum(num)
        pooh=poo//(x-2)
        print(pooh)
        num.clear()

Python: while True:
    n = int(input())
    numbers = []

    if n == 0:
        break

    for i in range(0, n):
        numbers.append(int((input())))

    maxValue = max(numbers)
    minValue = min(numbers)
    totalScore = sum(numbers)

    print(str(int((totalScore - maxValue - minValue) / (len(numbers) - 2))))

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

Python: def totalize(n):
    total = 0
    mins, maxs = (int(input()) for _ in range(2))
    if maxs < mins:
        maxs, mins = mins, maxs
    for _ in range(n - 2):
        s = int(input())
        if s < mins:
            s, mins = mins, s
        elif maxs < s:
            s, maxs = maxs, s
        total += s
    return total // (n - 2)

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

Python: while True:
    n = int(input())
    if n == 0:
        break
    tensu = []
    for i in range(1,n+1):
        s = int(input())
        tensu.append(s)
    m = min(tensu)
    M = max(tensu)
    tensu.remove(m)
    tensu.remove(M)
    t = len(tensu)
    sum = 0
    for j in range(0,t):
        sum += tensu[j]
    r = sum // t
    print(r)

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
	s = sorted([int(input()) for i in range(n)])
	s = s[1:-1]
	print(int(sum(s) / len(s)))

Python: #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    while True:
        n = II()
        if not n:
            break
        a = IR(n)
        a.sort()
        print(sum(a[1:-1])//(n-2))
            
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Python: while True:
    n=int(input())
    a=[]
    if n==0:
        break
    else:
        for i in range(n):
            a.append(int(input()))
    k=sorted(a)
    del k[0]
    del k[n-2]
    s=sum(k)
    print(int(s/(n-2)))

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

    if n == 0:
        break

    L = [int(raw_input()) for _ in range(n)]

    print (sum(L) - max(L) - min(L)) / (n - 2)

Python: while 1:
    n = int(input())
    if n == 0:
        break
    point = [int(input()) for i in range(n)]
    point.sort()
    Sum = 0
    hito = 0
    for i in range(1,n-1):
        Sum += point[i]
        hito += 1
    ans = Sum // hito
    print(ans)

Python: while True :
    n=int(input())
    if n==0:break
    ssum=0
    smax=0
    smin=1000
    for i in range(n):
        s=int(input())
        ssum+=s
        if smax<s : smax=s
        if smin>s : smin=s
    print((ssum-smax-smin)//(n-2))

Python: while 1:
    N = int(input())
    if N == 0:break
    print(int(sum(sorted([int(input()) for i in range(N)])[1:-1]) / (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 = 1
while n != 0:
    n = int(input())
    S = []
    S = [int(input()) for _ in range(n)]
    if n==0:
        break
    ans = (sum(S)-min(S)-max(S))/(n-2)
    Ans = int(ans)
    print(Ans)

Python: while 1:
    n = int(input())
    if n < 3 : break
    print(sum(sorted([int(input()) for x in [0]*n])[1:-1])//(n-2))