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: #-*- encoding:utf-8 -*-
import math

while 1:
    n = int(input())
    if n == 0:
        break
    max = 0
    min = 9999
    sum = 0
    for i in range(n):
        s = int(input())
        if max < s:
            max = s
        if min > s:
            min = s
        sum = sum + s
    ans = math.floor((sum - min - max) / (n-2))
    print(ans)

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

Python: while True:
    number = int(input())
    if number == 0:
        break
    point = [int(input()) for n in range(number)]
    point.sort() 
    point.pop(0) 
    point.pop(-1) 
    sumPoint = 0 
    numberSub = int(number) - 3
    while numberSub >= 0:
        sumPoint = sumPoint + int(point[numberSub - 1])
        numberSub = numberSub - 1
    average = sumPoint / (number -2)
    print (int(average))

Python: #-*- encoding:utf-8 -*-
import math

while 1:
    n = int(input())
    if n == 0:
        break
    max = 0
    min = 9999
    sum = 0
    for i in range(n):
        s = int(input())
        if max < s:
            max = s
        elif min > s:
            min = s
        sum = sum + s
    ans = math.floor((sum - min - max) / (n-2))
    print(ans)

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

Python: def tax(p,x):
    return p*(100+x) // 100 # 整数除算
def solve(X,Y,S):
    for a in range(1,S):
        for b in range(1,S):
            sum = tax(a,X)+tax(b,X)
            if sum == S:
# 新税でのtax(a,Y)+tax(b,Y) について検討 
                if sum > S:
                    break
# b増加ならばsum増加のため1 
    return best 
while True:
    X,Y,S = map(int, input().strip().split('')) 
    if X == 0:
        break
print(solve(X,Y,S))

Python: while True:
    n=int(input())
    if n==0:
        break
    data=[int(input()) for _ in range(n)]
    a=max(data)
    b=min(data)
    s=sum(data)
    s=s-a-b
    s=s//(n-2)
    print(s)

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 True:

  n = int(raw_input())

  if n == 0:
    break

  l = []

  for i in range(n):
    l.append(int(raw_input()))

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

Python: #1147
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
    
    s = []
    for i in range(n):
        s.append(int(input()))

    s.sort()
    s.pop(0)
    s.pop()
    
    print(int(sum(s)/len(s)))

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

Python: while True: #無限に繰り返す
 n = int(input()) #n に審判の数を読み込む
 if n == 0:
          break #n が 0 のときにループから抜ける
 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: Ps = []

while True:
    i = int(input())
    if i == 0:
        break
    P = []
    P.append(i)
    for ii in range(i):
        P.append(int(input()))

    Ps.append(P)

for p in Ps:
    p[0] = 0
    p.sort()
    p[1] = 0
    p[-1] = 0
    print(int(sum(p) / (len(p) - 3)))

Python: s=[]
while True:
    N=int(input())
    if N==0:
        break
    else:
        tmp=[int(input()) for _ in range(N)]
        tmp.sort()
        tmp=tmp[1:-1]
        s.append(tmp)

for si in s:
    N=len(si)
    ans=0
    for sij in si:
        ans+=sij
    ans//=N
    print(ans)

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

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

Python: while True:
	n = int(input())
	if n == 0:
	   break
	s, vn, vx = 0, 1001, -1
	for i in range(n):
		a = int(input())
		vn = min(vn, a)
		vx = max(vx, a)
		s += a
	print((s-vn-vx)//(n-2))

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

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

Python: i = int(input())
while i == 0:
    i = 0
    p = 0
    k[20][100] = [[0]]
    ma = 0
    mi = 1000
    for i in range(i):
        l = int(input())
        k[p][i] = l
        ma = max(ma,l)
        mi = min(mi,l)
    su = sum(k[p]) - ma - mi
    print(su // (i-2))
    p += 1
    i = int(input())

Python: while True:
    x=int(input())
    if x==0:
        break
    a=[]
    for i in range(x):
        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: #!/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:
    min = 1000
    max = 0
    sum = 0
    
    n=int(input())
    if n ==0:
        break
    for i in range(n):
        s=int(input())
        if s < min:
            min = s
        if s > max:
            max = s
        sum += s
    print((sum - min - max)//(n - 2))

Python: while True:
  N=int(input())
  if N==0:
    break
  s=list(int(input())for i in range(N))

  s.sort()
  del s[0]
  del s[-1]

  s_ave=sum(s)/len(s)
  print(int(s_ave))