Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

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

Python: #! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n = input()
            if n == 0:
                break
            p = []
            for i in range(n):
                p.append(input())
            print (sum(p) - min(p) - max(p)) / (n - 2)
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Python: person = int(input())
while person != 0:
    scores = []
    for i in range(person):
        scores.append(int(input()))     
    scores.sort()
    del scores[0]
    del scores[-1]
    print(int(sum(scores)/len(scores)))
    person = int(input())

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())
    if n == 0:
        break
    data = [int(input()) for z in range(n)]
        
    a = min(data)
    b = max(data)
    c = sum(data) - a - b

    print(c//(n-2))

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

    ma = 0
    mi = 1000
    s = 0

    for i in range(n):
        x = int(input())
        if ma < x:
            ma = x
        elif mi > x:
            mi = x
        s += x
    print ((s - ma - mi) // (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=sum+s
  print((sum-M-m)//(n-2))

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

Python: while True:
    n = int(input())
    if n == 0:
        break
    lista = []
    for i in range(n):
        lista.append(int(input()))
    lista.sort()
    lista.pop(0)
    lista.pop(-1)
    ave = sum(lista)//(n-2)
    print(ave)