Go: /*
	Problem A: ICPC 得点集計ソフトウェア
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
*/

package main

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

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

Python: ans_list = []

while True:
    n = int(input())
    if n == 0:
        break
    s = sorted([int(input()) for _ in range(n)])
    ans = sum(s[1:-1]) // (n-2)
    ans_list.append(ans)

for ans in ans_list:
    print(ans)

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

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

Python: while True:
  N = int(input())
  if N == 0:
    break
  L = []
  for i in range(N):
    L.append(int(input()))
  L.sort()
  A = sum(L)
  print((A-L[0]-L[len(L)-1])//(N-2))

Python: import math

def main():
    r = []
    while True:
        n = int(input())
        if n == 0:
            break
        m = []
        for i in range(n):
            m.append(int(input()))
        r.append(math.floor((sum(m) - max(m) - min(m)/(n-2))))
    res = ''
    for j in r:
        res += str(j)
    print(j)
    
main()

Python: import sys

while True:
    n = int(sys.stdin.readline().rstrip())

    if n == 0:
        break

    scores = [int(sys.stdin.readline().rstrip()) for i in range(n)]
    result = (sum(scores) - (max(scores) + min(scores))) // (n - 2)

    print(result)

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 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: while True:
    n=int(input())
    if n==0:
        break
    else:
        listA=[] 
        for i in range(n):
            listA.append(int(input()))
        print((sum(listA)-max(listA)-min(listA))//(n-2))

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

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

Python: averages = []

while True:
    amount = int(input())
    if amount == 0:
        break
    scores = [int(input()) for i in range(amount)]
    scores.remove(max(scores))
    scores.remove(min(scores))
    averages.append(sum(scores) // (amount - 2))

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

Python: import sys
F = sys.stdin
Continue = True
Ans = ""
while Continue:
    N = int(F.readline().strip("\n"))
    if N == 0:
        Continue = False
        break
    else:
        Score = [None] * N
        for i in range(N):
            Score[i] = int(F.readline().strip("\n"))
        Score.sort()
        Ans += str(sum(Score[1:N-1])//(N-2)) + "\n"
print(Ans)

Python: while True :
    N = int(input())
    if N == 0 :
        break
    data = list(int(input()) for i in range(N))
    
    data.sort()
    del data[0]
    del data[-1]
    
    data_ave = sum(data)/len(data)
    print(int(data_ave))

Python: while True:
    n = int(input())
    if n == 0:
        break
    else:
        intlist = []
        minval = 1001
        maxval = -1
        for i in range(n): #calculate max and min values, create list of all values
            a = int(input())
            if a >= maxval:
                maxval = a
            if a <= minval:
                minval = a
            intlist.append(a)
        total = 0
        mincheck = False
        maxcheck = False
        for i in range(len(intlist)): #add numbers together
            if(intlist[i] == minval and mincheck == False): #ignore min value once
                mincheck = True
            elif(intlist[i] == maxval and maxcheck == False): #ignore max value once
                maxcheck = True
            else:
                total += intlist[i]
        print(total//(len(intlist) - 2)) #print avg

Python: str=read()
print(str)
print("aaa")

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

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

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

Python: j = 0
lists = []
flag = 0
cnt = 0
while 1:
    cnt = 0
    flag_max = 0
    flag_min = 0
    lists = []
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        s = int(input())
        lists.append(s)
    for i in range(n):
        if lists[i] == max(lists):
            flag_max += 1
            pass
        elif lists[i] == min(lists):
            flag_min += 1
            pass
        else:
            cnt += lists[i]
    n -= 2
    if flag_max >= 2:
        cnt += max(lists)
    elif flag_min >= 2:
        cnt += min(lists)
    print(cnt // n)

Python: 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:
    # 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: while True:
    n = int(input())
    if n == 0:
        exit()
    score = []
    for i in range(n):
        score.append(int(input()))
    print(sum(sorted(score)[1:-1])//(n-2))

Python: # coding: utf-8

import sys

if __name__ == '__main__':
    while 1:
        n = int(input())
        if n == 0:
            break
        a = [int(input()) for i in range(n)]
        print((sum(a) - min(a) - max(a)) // (n-2));

Python: import math

def main():
    f = true
    r = []
    while f:
        n = int(input())
        if n == 0:
            break
        m = []
        for i in range(n):
            m.append(int(input()))
        r.append(math.floeor((sum(m) - max(m) - min(m)/(n-2))))
    res = ''
    for j in r:
        res += str(j)
    print(j)