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:
        a = int(input())
        if a == 0:
                break
         
        b = [int(input()) for i in range(a)]
        b.sort()
        bmin = min(b)
        bmax = max(b)
        bsum = sum(b)
        print((bsum-bmin-bmax)//(a-2))

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

Python: while True:
    n = int(input())
    max = 0
    min = 1000
    sum = 0
    if n == 0:
       break
    for i in range(n):

        s = int(input())
        sum += s
        if s < min:
            min = s
        if max < s:
            max = s
    ave = (sum - min - max) // (n - 2)
    print(ave)

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

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: while True:
    n = int(input())
    if n == 0:
        break
    else:
        lst=[]
        for i in range(n):
            s = int(input())
            lst.append(s)
        print((sum(lst)-max(lst)-min(lst))//(n-2))

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Problems 1157
Problem A: ICPC 得点集計ソフトウェア
"""
while True:
    n = int(input())
    if  n == 0:
        break
    sum, s_min, s_max = 0, 1001, -1
    for i in range(n):
        score = int(input())
        s_min = min(s_min, score)
        s_max = max(s_max, score)
        sum += score
    print((sum-s_min-s_max)//(n-2))

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: while True:
    P = []
    n = int(input())
    if n == 0:
        exit()
    for i in range(n):
        P.append(int(input()))
    print(sum(sorted(P)[1:-1]) // (n-2))

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

Python: str=readlines()
print(str)
print("aaa")

Python: while True:
    a=0
    ma=0
    mi=99999
    n = int(input())
    if n == 0:
        break
    else:
        for i in range(n):
            b=int(input())
            a=a+b
            if ma<b:
                ma=b
            if mi>b:
                mi=b
        answer=(a-ma-mi)//(n-2)
        print(answer)

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

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())
    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: import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    
    if n == 0:
        break
        
    scores = [int(sys.stdin.readline().rstrip()) for i in range(n)]
    result = (sum(scores) - (min(scores) + max(scores)) // n - 2)
    
    print(result)

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

Python: import math
while True:
    x = int(input())
    if x == 0:
        break
    a = list(int(input()) for i in range(x))
    
    a.sort()
    del a[0]
    del a[-1]
    
    b= sum(a)/len(a)
    print(math.floor(b))

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

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

Python: import math

def main():
    f = true
    r = []
    while f:
        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))))
    res = ''
    for j in r:
        res += str(j)
    print(j)
    
main()

Python: while True: #無限に繰り返す
    num = int(input()) #標準入力
    if num == 0:break #入力値が0だった場合繰り返しを強制終了する
    else: #0でなければ
        num_list = [] #空リスト作成
        for _ in range(num): #入力回繰り返す
            num_list.append(int(input())) #標準入力をし、リストに加える
        num_list.sort() #リストを小さい順に並べる
        num_list.pop(-1) #リストの最高点を削除する
        num_list.pop(0) #リストの最低点を削除する
        num = sum(num_list) #リストの値を合計する
        num1 = len(num_list) #リストの長さを取得する
        print(int(num / num1)) #リストの平均を出力する

Python: while True:
    n = int(input())
    if n == 0:
        exit()
    score = []
    for i in range(n):
        score.append(int(input()))
    print(sum(sorted(score)[1:-1]))

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: while True:
    n = int(input())
    if not(n): break
    s = sum(sorted([int(input()) for i in range(n)])[1:-1])
    print(s//(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: while 1:
    n=int(input())
    if n==0:break
    a=[int(input()) for _ in range(n)]
    print((sum(a)-max(a)-min(a))//(n-2))

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

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

    s = [int(input()) for i in range(n)]

    s.sort()
    #print(s)
    ans = sum(s[1:n - 1]) // (n - 2)
    print(ans)

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