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: #(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)
    y=(c-a-b)//(n-2)
    
    print(y)

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

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

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

Python: """
Problem A: ICPC 得点集計ソフトウェア
"""
if __name__ == '__main__':
    ans = []
    while(True):
        n = int(input())
        if n == 0:
            break
            
        l = [int(input()) for _ in range(n)]
        maxi = max(l)
        mini = min(l)
        ans.append((sum(l) - maxi - mini)//(n-2))
    print(*ans, sep='\n')

Python: import bisect
while True:
    n = int(input())
    if n == 0:
        break
    score = []
    for _ in range(n):
        s = int(input())
        bisect.insort(score, s)
    print(sum(score[1:-1])//(len(score)-2))

Python: # ICPC Score Totalizer Software

ans = []

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

for i in range(len(ans)):
    print(ans[i])

Python: i = int(input())
p = 0
while i != 0:
    k =[ [0]*100]*20
    ma = 0
    mi = 1000
    for pp in range(i):
        l = int(input())
        k[p][pp] = l
        ma = max(ma,l)
        mi = min(mi,l)
    su = sum(k[p]) - ma - mi
    l = i -2
    print(su // l)
    p += 1
    i = int(input())

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

Python: #!/usr/bin/python --
import sys

#2007 Domestic A
def judge(n):
  ma=0
  mi=1000
  s=0
  for i in range(0,n):
    x=int(sys.stdin.readline())
    if x<mi:
      mi=x
    if x>ma:
      ma=x
    s+=x
  print (s-ma-mi)/(n-2)

while 1:
  n=int(sys.stdin.readline())
  if n==0:
    break
  judge(n)

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

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

Python: while 1:
    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())
    points=[]
    for i in range(n):
        points.append(int(input()))
    points.remove(max(points))
    points.remove(min(points))
    print(sum(points)/len(points))
    if int(input())==0:break

Python: import math
while True:
  n=int(input())
  if n==0:
    break
  else:
    S_list=[]
    for i in range(n):
      score=int(input())
      S_list.append(score)
    S_list.remove(max(S_list))
    S_list.remove(min(S_list))
    print(math.floor(sum(S_list)/len(S_list)))

Python: while True:
    n = int(input())#n=0は終わり
    s = 0
    if n==0:
        break
    else:
        b=[]
        for i in range(n):
            a = int(input())#審判の点数
            b.append((a))
        b.sort()#全員分入力してからソート
        b.pop(n-1)#listが崩れるからz-1から抜いていく
        b.pop(0)
        s=sum(b) #bのリストのI番目をたす
        ave= s/(n-2)
        print(int(ave))

Python: def main():
    while True:
        n = int(input())
        if n == 0:break
        a = []
        for i in range(n):
            a.append(int(input()))
        a.sort()
        sum = 0
        for i in range(1,n-1):sum+=a[i]
        print(sum//(n-2))


if __name__ == '__main__':
    main()

Python: while True:
    n = int(input())
    if n==0: 
        break
    l = []
    for i in range(n):
        x = int(input())
        l.append(x)
    l.sort()
    a = sum(l)-(max(l)+min(l))
    print(a//(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: if __name__ == '__main__':
    while True:
        N = int(input())
        if N == 0:
            break

        arr = []
        for _ in range(N):
            arr.append(int(input().strip()))
        
        n = sum(arr)
        n -= max(arr) + min(arr)

        print(n // (N - 2))

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

Python: while 1:
    n = int(input())
    if n < 3 : break
    print(sum(sorted([int(input()) for x  in [0]*n])[1:-1])//(n-2))

Python: while 1:
    n=int(input())
    if n==0:break
    score=[]
    for i in range(n):
        score.append(int(input()))
    score.sort()
    score=score[1:-1]
    print(sum(score)//len(score))

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 :
    num = int(input())
    if num == 0 :
        break
    A = []
    for i in range(num):
        sco = int(input())
        A.append(sco)
        A.sort()
    del A[num - 1]
    del A[0]

    B = int(sum(A)/(num-2))
    print(B)

Python: import math
while True:
    n=int(input())
    if n==0:
        break
    l=[]
    for i in range(n):
        l.append(int(input()))
    slist=sorted(l)
    del slist[0]
    del slist[n-2]
    x=sum(slist)/len(slist)
    print(math.floor(x))

Python: while True:
    judges = int(input())
    if not judges:
        break
    a = [int(input()) for i in range(judges)]
    a.remove(max(a))
    a.remove(min(a))
    print(int(sum(a) / len(a)))

Python: # -*- coding: utf-8 -*-

def main():
    while 1:
        n = int(input())
        if n == 0:
            return 0
        s_l = []
        for _ in range(n):
            s_l.append(int(input()))
        ans = int((sum(s_l) - max(s_l) - min(s_l))/(n-2))
        print(ans)

if __name__ == "__main__":
    main()

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

Python: # coding: utf-8
while True:
    n = int(input())
    if n == 0:
        break
    t = 0
    ma = 0
    mi = 1000
    for i in range(n):
        s = int(input())
        t += s
        if(s > ma):
            ma = s
        if(s < mi):
            mi = s
    print((t - ma - mi) // (n - 2))

Python: import sys
while 1:
    n=int(input())
    if n==0:
        sys.exit()
    l=[0]*n
    ma=0
    mi=1000
    s=0
    for i in range(n):
        l[i]=int(input())
        s+=l[i]
        if l[i]>ma:
            ma=l[i]
        if l[i]<mi:
            mi=l[i]
        
    print ((s-ma-mi)//(n-2))