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())
		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 < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

Python: result = []
while True:
    no_referee = int(input())
    if no_referee == 0:
        break
    else:
        sum_score = 0
        max_score = 0
        min_score = 1000
        for i in range(no_referee):
            score = int(input())
            sum_score += score
            if score > max_score:
                max_score = score
            if score < min_score:
                min_score = score
        sum_score = sum_score - max_score - min_score
        result.append(int(sum_score/(no_referee-2)))

for r in result:
    print(str(r))

Python: import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    while True:
        n = I()
        if n == 0:
            break
        a = sorted([I() for _ in range(n)])
        r = sum(a[1:-1]) // (n-2)
        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())

Python: while True:
    n=int(input())
    list=[]
    if n==0:
        break
    for i in range(n):
        list.append(int(input()))
    list.sort()
   
    ave=(sum(list)-list[0]-list[-1])//(n-2)
    print(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: import math
while True:
    n = int(input())
    scores = [int(input()) for i in range(n)]
    scores.sort()
    
    if n == 0:
        break
    total = 0
    
    for i in range(1, n - 1):
        total += scores[i]
        
    print(math.floor(total / (n - 2)))

Python: import sys

while True:
    n = int(input())
    if n == 0:
        break
    print( int( sum( sorted( [int(input()) for x in range(0, n)] )[1:-1] )/(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))
    
    if n==0:break

Python: def average(points):
    sum = 0
    for i in points:
        sum += i
    return sum / len(points)

outputs = []

while True:
    num = int(input())
    if num == 0:
        break

    points = []
    for _ in range(num):
        point = int(input())
        points.append(point)

    points = sorted(points)
    points = points[1:len(points)-1]

    ave = average(points)
    outputs.append(int(ave))

for ave in outputs:
    print(ave)

Python: N=int(input())
while N!=0:
    data=[]
    for i in range(N):
        data.append(int(input()))
    data.sort()
    Sum=0
    Count=0
    for i in range(N-2):
        Sum+=data[i+1]
        Count+=1
    print(Sum//Count)
    N=int(input())

Python: while True :
    
    n=int(input())
    if n==0 :
        break
    
    i=0
    b=0
    ma=0
    mi=1000
    while i<n :
        c=int(input())
        if ma<c :
            ma=c
        if mi>c :
            mi=c
        b=b+c
        i=i+1
    print(int((b-ma-mi)/(n-2)))

Python: # coding: utf-8
# Here your code !
fin = False
while fin == False:
    lists = []
    times = int(input())
    if times == 0:
        fin == True
        break
    else:
        for i in range(times):
            a = int(input())
            lists.append(a)
        lists.remove(max(lists))
        lists.remove(min(lists))
        s = 0
        for i in lists:
            s+=i
        result = int(s/len(lists))
        print(result)

Python: while True:
    n = int(input())
    if not n:
        break
    print(sum(sorted([int(input()) for _ in range(n)])[1:-1]) // (n - 2))

Python: while True:
    n=int(input())
    if n == 0:
        break
    else:
        li1=[0]*n
    
        #t=1
        for t in range(n):  
            li1[t]=int(input())
        s=int((sum(li1)-max(li1)-min(li1))/(n-2))
        print(s)

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

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: import sys
import math
input = sys.stdin.readline
##

num_score = int(input().rstrip())
while num_score != 0:
    scores = []
    for _ in range(num_score):
        scores.append(int(input().rstrip()))
    total = sum(scores) - max(scores) - min(scores)
    average = math.floor(total / (len(scores) - 2))
    print(average)
    num_score = int(input().rstrip())

Python: # 演習１－１２
while True:
    a = int(input())
    if a == 0:
        break
    else:
        li = [0]*a
        for i in range(a):
            li[i] = int(input())
        li_sort = sorted(li)
        del li_sort[0]
        del li_sort[-1]
        print(int(sum(li_sort)/len(li_sort)))

Python: while True:
        a = int(input())
        if a == 0:
                break
         
        b = [int(input()) for i in range(a)]
        b.sort()
        bmin = min(b)
        bmax = max(b)
        bsum = sum(b)
        print((bsum-bmin-bmax)//(a-2))

Python: while True:
    n=int(input())
    if n==0:
        break
    i=1
    sum=0
    max=0
    min=1000
    while i<=n:
        a=int(input())
        if max<a:
            max=a
        if min>a:
            min=a
        sum+=a
        
        
        i+=1
    sum=sum-max-min
    print(int(sum/(n-2)))

Python: while True:
    n = int(input())
    max = 0
    min = 1000
    sum = 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(raw_input())
    if n == 0:
        break
    a = sorted([int(raw_input()) for _ in xrange(n)])
    print (sum(a)-a[0]-a[-1])/(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())
    if n == 0:
        break
    else:
        lst=[]
        for i in range(n):
            s = int(input())
            lst.append(s)
        print((sum(lst)-max(lst)-min(lst))//(n-2))

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Problems 1157
Problem A: ICPC 得点集計ソフトウェア
"""
while True:
    n = int(input())
    if  n == 0:
        break
    sum, s_min, s_max = 0, 1001, -1
    for i in range(n):
        score = int(input())
        s_min = min(s_min, score)
        s_max = max(s_max, score)
        sum += score
    print((sum-s_min-s_max)//(n-2))

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