Go: package main

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

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

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

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

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

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

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)