Go: package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (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))

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 True:
    n = int(input())
    slist = []
    for i in range(n):
        s = int(input())
        slist.append(s)
    
    if n==0:
        break
    
    for j in range(n):
        for k in range(n-1,0,-1):
            if slist[k-1]>slist[k]:
                slist[k-1],slist[k] = slist[k],slist[k-1]
    
    slist.pop(0)
    slist.pop(n-2)
    
    ave = sum(slist)//len(slist)
        
    print(ave)

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

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

    s.remove(max(s)); s.remove(min(s))
    print(sum(s)//len(s))

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

Python: while True:
    n=int(input())
    if n == 0:
        break
    b=[]
    for i in range(n):
        a=int(input())
        b.append(a)
    c=sorted(b)
    if n == 3:
        print(c[1])
    elif n >= 4:
        d=sum(c)-c[0]-c[n-1]
        e=n-2
        print(d//e)

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

Python: import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    while 1:
        n=II()
        if n==0:break
        aa=[II() for _ in range(n)]
        aa.sort()
        print(sum(aa[1:n-1])//(n-2))

main()

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: n = int(input())
s = 0

while n != 0:
    a = [int(input()) for i in range(n)]
    b = sorted(a)
    for i in range(1,n-1):
        s += b[i]
    c = s//(n-2)
    print('{:.0f}'.format(c))
    n = int(input())
    s = 0

Python: while True:
  n=int(input()) #審判の数
  if n==0:#入力終了
   break
  l=[]
 
  s=0
  for i in range(n):
    j=int(input()) #得点
    l.append(j)
    s+=j
  print((s-max(l)-min(l)) //(n-2))