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:
    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: #!/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())
    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: import statistics

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

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

Python: for x in range(20):
    a=int(input())
    if a==0: break
    
    lst = []
    for x in range(a):
        lst.append(int(input()))
    b=min(lst)
    c=max(lst)
    lst.remove(b)
    lst.remove(c)
    d=sum(lst)
    ave=d//(a-2)
    print(ave)

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)
     d=(c-a-b)//(n-2)
     print(d)

Python: # your code goes here
n=int(input())
while n!=0:
    s=int(input())
    x=s
    m=s
    for i in range (n-1):#n-2?:?
        p=int(input ())
        if m>p:
      #      s+=m
            m=p
        elif x<p:
        #    s+=x
            x=p
    #    else:
        s+=p
   #     print (s)
    s-=x
    s-=m
    s/=n-2
    print(int(s))
    n=int(input())

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

Python: while True:
    n=int(input())
    if n==0:
        break
    m=10000
    M=0
    sum=0
    for i in range(n):
        s=int(input())
        m=min(m,s)
        M=max(M,s)
        sum+=s
    print((sum-M-m)//(n-2))

Python: import math
while True:
    x=[]
    y=0
    n=int(input())
    if n==0:
        break
    for i in range(n):
        s=int(input())
        x+=[s]
    #print(x)
    
    x.remove(max(x))
    #print(x)
    x.remove(min(x))
    #print(x)
    
    
    for j in range(n-2):
        y+=x[j]
    
    #print(y)
    
    print(
        math.floor(y/(n-2))
        )

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

Python: while True:
    n = int(input())
    max = 0
    min = 1000
    sum = 0
    ave = 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(input())
    if n == 0:
        exit()
    score = []
    for i in range(n):
        score.append(int(input()))
    print((sorted(score)[1:-1])//(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: while True:
    n=int(input())
    max=0
    min=1000
    sum=0
    ave=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: # -*- coding: utf-8 -*-

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

    n = int(raw_input())

Python: # ????°??????¨?????§????????????????????????????????????
while True:
    # n : num of judges
    n = int(input())
    if n == 0:
        break

    scores = []
    for i in range(n):
        scores.append(int(input()))

    final_score = int( (sum(scores) - max(scores) - min(scores)) / (n - 2) )
    print(final_score)

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

Python: def score(li):
    li.remove(max(li))
    li.remove(min(li))
    return int(sum(li) / (len(li)))

while 1:
    n = int(input())
    if n == 0: # ???????????¶
        break
    s = [int(input()) for i in range(n)]
    print(score(s))

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

Python: # coding: utf-8
# Your code here!
while(1):
    risuto = []
    num = int(input())
    if num == 0 :
        break
    for i in range(num):
        risuto.append(int(input()))
    print((sum(risuto)-max(risuto)-min(risuto))//(num-2))

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

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

print("\r\n".join(array))

Python: for i in range(20):
    n = int(input())
    
    if n == 0:
        break
    
    data = list()
    for j in range(n):
        a = int(input())
        data.extend([a])
    #print(data)
    
    x = sum(data) - min(data) - max(data)
    #print(x)
    print(x // (n-2) )

Python: # AOJ 1147: ICPC Score Totalizer Software
# Python3 2018.7.14 bal4u

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))