Problem:


Problem A: ICPC Score Totalizer Software

The International Clown and Pierrot Competition (ICPC), is one of the
most distinguished and also the most popular events on earth in the
show business.

One of the unique features of this contest is the great number of
judges that sometimes counts up to one hundred.  The number of judges
may differ from one contestant to another, because judges with any
relationship whatsoever with a specific contestant are temporarily
excluded for scoring his/her performance.

Basically, scores given to a contestant's performance by the judges
are averaged to decide his/her score.  To avoid letting judges with
eccentric viewpoints too much influence the score, the highest and the
lowest scores are set aside in this calculation.  If the same highest
score is marked by two or more judges, only one of them is ignored.
The same is with the lowest score.  The average, which may contain
fractions, are truncated down to obtain final score as an integer.

You are asked to write a program that computes the scores of
performances, given the scores of all the judges, to speed up the event
to be suited for a TV program.

Input

The input consists of a number of datasets, each corresponding to a
contestant's performance.  There are no more than 20 datasets in the input.

A dataset begins with a line with an integer n, the number of
judges participated in scoring the performance (3 ≤ n ≤
100).  Each of the n lines following it has an integral
score s (0 ≤ s ≤ 1000) marked by a judge.  No
other characters except for digits to express these numbers are in the
input.  Judges' names are kept secret.

The end of the input is indicated by a line with a single zero in it.

Output

For each dataset, a line containing a single decimal integer
indicating the score for the corresponding performance should be
output.  No other characters should be on the output line.

Sample Input

3
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
400
8
353
242
402
274
283
132
402
523
0

Output for the Sample Input

342
7
300
326



Sample input:
3
1000
342
0
5
2
2
9
11
932
5
300
1000
0
200
400
8
353
242
402
274
283
132
402
523
0


Sample output:
342
7
300
326

Submission status: Wrong Answer

Solution code:
while 1:
	n = input()
	if n == 0:
		break
	a = []
	for i in range(n):
		s = input()
		a.append(s)
	del a[n-1]
	del a[0]
	print sum(a)/(n-2)

Submission status: Wrong Answer

Solution code:
j = 0
lists = []
flag = 0
cnt = 0
while 1:
    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 += 1
            pass
        elif lists[i] == min(lists):
            flag += 1
            pass
        else:
            cnt += lists[i]
    if flag >= 2:
        n -= 2
    print(cnt // n)

Submission status: Wrong Answer

Solution code:
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]))

Submission status: Wrong Answer

Solution code:
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)

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

Submission status: Wrong Answer

Solution code:
a=100

Submission status: Wrong Answer

Solution code:
while True:
    n = int(raw_input())
    if n == 0:
        break

    ma = 0
    mi = 1000
    s = 0

    for i in range(n):
        x = int(raw_input())
        if ma < x:
            ma = x
        elif mi > x:
            mi = x
        s += x
    print (s - ma - mi) / (n - 2)

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
while True:
    n = int(raw_input())
    if n == 0:
        break

    ma = 0
    mi = 1000
    s = 0

    for i in range(n):
        x = int(raw_input())
        if ma < x:
            ma = x
        elif mi > x:
            mi = x
        s += x
    print ((s - ma - mi) // (n - 2))

Submission status: Wrong Answer

Solution code:
#coding:utf-8

while True:
	#??????????????¨??´??°???
	n = int(raw_input())

	#?????????????????¶
	if n == 0: break

	else:
		#n??????
		for i in range(n):

			#????????????
			score = int(raw_input())
			print "score: %d (%d/%d)" % (score,i+1,n)

Submission status: Wrong Answer

Solution code:
#coding:utf-8

while True:
	#??????????????¨??´??°???
	n = int(raw_input())
	#?????????????????¶
	if n == 0: break

	else:
		print str(n) + "??????????????°"
		list = []
		#n??????
		for i in range(n):

			#????????????
			score = int(raw_input())
			print "score: %d (%d/%d)" % (score,i+1,n)
			list.append(score)
		list.sort();
		list.pop(0);
		list.pop();
		x = sum(list) / (n-2)
		print "?????£????????°???" + str(x)

Submission status: Wrong Answer

Solution code:
import statistics

while True:
    n = int(input())
    if n == 0: break
    s = [int(input()) for i in range(n)]
    ave = statistics.mean(s[1:-1])
    print(int(ave))

Submission status: Wrong Answer

Solution code:
import statistics

while True:
    n = int(input())
    if n == 0: break
    s = [int(input()) for i in range(n)]
    ave = statistics.mean(sorted(s[1:-1]))
    print(int(ave))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#-*- encoding:utf-8 -*-
import math

while 1:
    n = int(input())
    if n == 0:
        break
    max = 0
    min = 9999
    sum = 0
    for i in range(n):
        s = int(input())
        if max < s:
            max = s
        elif min > s:
            min = s
        sum = sum + s
    ans = math.floor((sum - min - max) / (n-2))
    print(ans)

Submission status: Wrong Answer

Solution code:
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) - (min(scores) + max(scores)) // n - 2)
    
    print(result)

Submission status: Wrong Answer

Solution code:
while True:
    try:
        n = int(input())
        MIN = 1000
        MAX = 0
        points = 0
        for i in range(n):
            p = int(input())
            if MIN > p:
                MIN = p
            if MAX < p:
                MAX = p
            points += p
        print((points - MIN - MAX) // (n - 2))
    except:
        break

Submission status: Wrong Answer

Solution code:
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.floor((sum(m) - max(m) - min(m)/(n-2))))
    res = ''
    for j in r:
        res += str(j)
    print(j)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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()

Submission status: Wrong Answer

Solution code:
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(res)

main()

Submission status: Wrong Answer

Solution code:
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:
        print(j)

main()

Submission status: Wrong Answer

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

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:break
    a=0
    mi=1145141919
    ma=0
    for i in range(n):
        t=int(input())
        mi=min(mi,t)
        ma=max(ma,t)
        a+=t
    a-=mi+ma
    print(a//(n-2))

Submission status: Accepted

Solution code:
while True:
    number = int(input())
    if number == 0:
        break
    point = [int(input()) for n in range(number)]
    point.sort() 
    point.pop(0) 
    point.pop(-1) 
    sumPoint = 0 
    numberSub = int(number) - 3
    while numberSub >= 0:
        sumPoint = sumPoint + int(point[numberSub - 1])
        numberSub = numberSub - 1
    average = sumPoint / (number -2)
    print (int(average))

Submission status: Accepted

Solution code:
# 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))

Submission status: Accepted

Solution code:
while 1:
	n = input()
	if n == 0:
		break
	a = []
	for i in range(n):
		s = input()
		a.append(s)
	a = sorted(a)
	del a[n-1]
	del a[0]
	print sum(a)/(n-2)

Submission status: Accepted

Solution code:
import sys
F = sys.stdin
Continue = True
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()
        print(sum(Score[1:N-1])//(N-2))

Submission status: Accepted

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

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

    s.sort()
    #print(s)
    ans = sum(s[1:n - 1]) // (n - 2)
    print(ans)

Submission status: Accepted

Solution code:
while True:
    #審判の数
    n = int(input())
    if n == 0:
        break
    a = [0]*n               #空いてる配列
    for i in range(n):       #空いてる配列に点数を入れる
        s = int(input())
        a[i] = s
    tensu = (sum(a) - min(a) -max(a))/(len(a)-2) #一番でかい点数と一番小さい点数は一つずつ引いて平均
    print(int(tensu))        #平均点！

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

while True:
    n = inp()
    if n == 0:
        break
    else:
        aa = [inp() for i in range(n)]
        aa.sort()
        print(sum(aa[1:n-1])//(n-2))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:exit()
    l=[ int(input()) for i in range(n) ]
    print(int((sum(l)-max(l)-min(l))/(n-2)))

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
while 1:
    n = input()
    if n == 0:
        break
    s = [input(), input()]
    if s[0] > s[1]:
        max = 0
        min = 1
    else:
        max = 1
        min = 0
    for i in range(2, n):
        s.append(input())
        if s[i] > s[max]:
            max = i
        elif s[i] < s[min]:
            min = i
    s[max] = 0
    s[min] = 0
    sum = 0
    for i in range(n):
        sum += s[i]
    ave = sum / (n-2)
    print ave

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
#! /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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/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))

Submission status: Accepted

Solution code:
n = int(raw_input())
while n != 0:
	l = list()
	for i in range(n):
		l.append(int(raw_input()))
	print int((sum(l)-max(l)-min(l)) / (n-2))
	n = int(raw_input())

Submission status: Accepted

Solution code:
# -*- 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())

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

def main(n):
    mi=1000
    ma=0
    su=0
    for i in range(n):
        num = int(raw_input())
        su += num
        ma = max(ma, num)
        mi = min(mi, num)
    su -= ma + mi
    print su/(n-2)

while 1:
    n = int(raw_input())
    if n==0:
        break
    main(n)

Submission status: Accepted

Solution code:
#!/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

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0: break
    
    l=[]
    for _ in range(n):
        l.append(int(input()))
    l.sort()
    print(sum(l[1:-1])//(n-2))

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
#ICPC得点集計ソフトウェア
import sys
def solve(n):
	nums = []
	for i in xrange(n):
		temp = input()
		nums.append(temp)
	nums.sort()
	sum = 0
	for i in xrange(1,n-1):
		sum += nums[i]
	return sum / (n-2)


if __name__ == "__main__":
	while 1:
		N = input()
		if N == 0:
			sys.exit()
		else:
			print solve(N)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
while True:
    n = input()
    if n==0:
        break
    list = []
    for i in range(0,n):
        tmp = input()
        list.append(tmp)
    list.sort()
    list.pop()
    list.pop(0)
    sum = 0
    for i in range(0,len(list)):
        sum += list[i]
    print sum/(n-2)

Submission status: Accepted

Solution code:
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
        if mi > x:
            mi = x
        s += x

    
    print ((s - ma - mi) // (n - 2))

Submission status: Accepted

Solution code:
f = True
while f:
    x = raw_input()
    x = int(x)
    l = []
    for i in range(x):
        l.append(int(raw_input()))
    if x == 0:
        f = False
    else:
        print (sum(l) - min(l) - max(l)) / (len(l) - 2)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math
import statistics


def get_average_score(scores):
    return math.floor(statistics.mean(sorted(scores)[1: -1]))


if __name__ == "__main__":
    while True:
        n = int(input())
        if n == 0:
            break
        else:
            print(get_average_score(int(input()) for i in range(n)))

Submission status: Accepted

Solution code:
def scoring():
    n = int(raw_input())
    if n is 0:
        return
    scores = [int(raw_input()) for _ in range(n)]
    scores.sort()
    if len(scores) < 2:
        return 0
    score = sum(scores[1:-1]) / (n-2)
    return score

while True:
    score = scoring()
    if score is None:
        break
    print score

Submission status: Accepted

Solution code:
def totalize(n):
    total = 0
    mins, maxs = (int(input()) for _ in range(2))
    if maxs < mins:
        maxs, mins = mins, maxs
    for _ in range(n - 2):
        s = int(input())
        if s < mins:
            s, mins = mins, s
        elif maxs < s:
            s, maxs = maxs, s
        total += s
    return total // (n - 2)

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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
r = []
while True:
    n = int(input())
    if n == 0:
        break
    p = []
    for i in range(n):
        p.append(int(input()))
    p.remove(min(p))
    p.remove(max(p))
    r.append(sum(p)//len(p))
[print(i) for i in r]

Submission status: Accepted

Solution code:
trial = int(input())
while True:
    targ = []
    for t in range(trial):
        targ.append(int(input()))
    targ.remove(max(targ))
    targ.remove(min(targ))
    print(sum(targ) // len(targ))
    trial = int(input())
    if trial ==0:
        break

Submission status: Accepted

Solution code:
while True:

  n = int(raw_input())

  if n == 0:
    break

  l = []

  for i in range(n):
    l.append(int(raw_input()))

  print (sum(l) - max(l) - min(l)) / (n - 2)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if not n:
        break
    data = [int(input()) for i in range(n)]
    data.sort()
    print int(sum(data[1:-1]) / (n - 2))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
while True:
    n = int(raw_input())
    if n == 0:
        break
    else:
        l = []
        for i in range(n):
            num = int(raw_input())
            l.append(num)
            l.sort()
        l = l[1:-1]
        ave = float(sum(l))/len(l)
        print int(ave)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 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))

Submission status: Accepted

Solution code:
#!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)

Submission status: Accepted

Solution code:
while True:
	n = int(raw_input())
	if n == 0: break

	else:
		list = []
		for i in range(n):
			score = int(raw_input())
			list.append(score)
		list.sort();
		list.pop(0);
		list.pop();
		x = sum(list) / (n-2)
		print x

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    a=[int(input()) for _ in range(n)]
    print((sum(a)-max(a)-min(a))//(n-2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
import statistics

while True:
    n = int(input())
    if n == 0: break
    s = [int(input()) for i in range(n)]
    ave = statistics.mean(sorted(s)[1:-1])
    print(int(ave))

Submission status: Accepted

Solution code:
import sys

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

    if n == 0:
        break

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

    print(ans)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n==0: break
    a = []
    for _ in range(n):
        a.append(int(input()))
    a.sort()
    a.pop()
    a.pop(0)
    print(sum(a)//(n-2))

Submission status: Accepted

Solution code:
import math
while(1):
    n = int(input())
    if (n == 0):
        break
    a = [int(input()) for i in range(n)]

    a.sort()
    del a[0]
    del a[-1]
    sum = 0
    for i in range(n-2):
        sum += a[i]
    sum = math.floor(sum / (n-2))

    print("%d" % sum)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# ????°??????¨?????§????????????????????????????????????
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)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    
    else:
        score=[]
        for i in range(n):
            score.append(int(input()))
        score.sort()
        score.pop(0)
        score.pop(-1)
        sum=0
        for i in range(n-2):
            sum+=score[i]
        print(int(sum/(n-2)))

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
# 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));

Submission status: Accepted

Solution code:
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = []
    for i in range(n):
        s.append(int(input()))
    print(math.floor((sum(s) - min(s) - max(s)) / (n - 2)))

Submission status: Accepted

Solution code:
# 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)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n < 3:
        break
    print(sum(sorted([int(input()) for i in range(n)])[1:-1]) // (n - 2))

Submission status: Accepted

Solution code:
#-*- encoding:utf-8 -*-
import math

while 1:
    n = int(input())
    if n == 0:
        break
    max = 0
    min = 9999
    sum = 0
    for i in range(n):
        s = int(input())
        if max < s:
            max = s
        if min > s:
            min = s
        sum = sum + s
    ans = math.floor((sum - min - max) / (n-2))
    print(ans)

Submission status: Accepted

Solution code:
#-*- coding:utf-8 -*-


def judge(a,n):
    a.sort()
    del a[0]
    del a[-1]
    sum = 0
    for i in range(len(a)):
        sum += a[i]
    return int(sum / len(a))

while(1):
    n = int(input())
    if (n == 0):
        exit(0)
    else:
        a = [int(input()) for i in range(n)]
        print(judge(a,n))

Submission status: Accepted

Solution code:
while True:
    n=int(input())

    if n==0:
        break
    a=[]
    for i in range(n):
        a=a+[int(input())]
    sum=0
    for i in range(n):
        sum+=a[i]

    score=int((sum-max(a)-min(a))/(n-2))
    print(score)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import math
import copy

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)

Submission status: Accepted

Solution code:
while True:
    n = int(raw_input())
    if n == 0: break
 
    else:
        list = []
        for i in range(n):
            score = int(raw_input())
            list.append(score)
        list.sort();
        list.pop(0);
        list.pop();
        x = sum(list) / (n-2)
        print x

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:break
    points=[]
    for i in range(n):
        points.append(int(input()))
    points.remove(max(points))
    points.remove(min(points))
    print(int(sum(points)/len(points)))

Submission status: Accepted

Solution code:
if  __name__ == "__main__":
    while True:
        dataset = []
        n = 0
        n = int(input())
        if n== 0: break
        for i in range(n):
            dataset.append(int(input()))
        print(int(((sum(dataset) - min(dataset) - max(dataset))/(n - 2))))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 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))