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: 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: ans = []
while True:
    n = int(input())
    if n == 0:
        break
    score = [int(input()) for i in range(n)]
    score.sort()
    ans.append(sum(score[1:-1]) // len(score[1:-1]))

for i in ans:
    print(i)

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

Python: while True:
    n=int(input())
    if n==0:
        break
    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: 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
    return best 
while True:
    X,Y,S = map(int, input().strip().split('')) 
    if X == 0:
        break
print(solve(X,Y,S))

Python: import sys
if sys.version_info[0]>=3: raw_input=input

def judge(n):
  ma=0
  mi=1000
  s=0
  for i in range(0,n):
    x=int(raw_input())
    if x<mi:
      mi=x
    if x>ma:
      ma=x
    s+=x
  print((s-ma-mi)//(n-2))

while 1:
  n=int(raw_input())
  if n==0:
    break
  judge(n)

Python: while True :
    n=int(input())
    if n==0:
        break
    su,amin,amax=0,1000,0
    for i in range(n):
        a=int(input())
        amin=min(amin,a)
        amax=max(amax,a)
        su+=a
    print((su-amin-amax)//(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: list1=[]
while True: 
    n = int(input())
    if n == 0:
        break #n が 0 のときにループから抜ける
    else:
        for i in range(n):
            j=int(input())
            list1.append(j)
        list1.remove(max(list1))
        list1.remove(min(list1))
        print(sum(list1)//len(list1))
        list1=[]

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

Python: while True: 
    n = int(input())
    S = []
    if n==0:
        break
    for i in range(n):
        S.append(int(input()))
    #print(S)
    S.sort()
    #print(S)
    S.pop(0)
    S.pop()
    #print(S)

    print(sum(S)//(n-2))

Python: # coding: utf-8
# Your code here!

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