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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):



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

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

Solution (Python):



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

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

Solution (Python):


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

Solution (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

Solution (Python):

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

Solution (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

Solution (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

Solution (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

Solution (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

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

Solution (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])

Solution (Python):


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)

Solution (Python):

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

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

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

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

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

Solution (Python):



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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):

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

Solution (Python):



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)

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
while True:
    
    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)

Solution (Python):

while True:
    
    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)

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

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

Solution (Python):


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

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

Solution (Python):


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)

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

Solution (Python):

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)

Solution (Python):



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

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

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

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

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

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

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

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

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

Solution (Python):


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

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    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))

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

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

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

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

if __name__=="__main__":
	main()

Solution (Python):
while True:
    n = int(raw_input())

    if n == 0:
        break

    L = [int(raw_input()) for _ in range(n)]

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

Solution (Python):
while(True):
    x = input()
    x= int(x)
    if x==0:
        break
    max_p = 0
    min_p= 1000
    total = 0
    for n in range(x):
        point = input()
        point = int(point)
        total += point
        if max_p < point:
            max_p =  point
        if min_p > point:
            min_p = point
    ans = total - max_p -min_p
    ans /= x-2
    ans = int(ans)
    print(ans)

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

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

Solution (Python):
while(True):
  n = int(input())
  if n == 0:
    quit()
  a = []
  for i in range(n):
    a.append(int(input()))
  a.sort()
  a = a[1:-1]
  ans = 0
  for j in a:
    ans += j
  print(ans//len(a))

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

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

Solution (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)))
    for j in r:
        print(j)

main()

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

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

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

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

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

Solution (Python):
import math
while True:
    n = int(input())
    if n == 0 :
        break
    sum = []
    for i in range(n):
        x = int(input())
        sum.append(x)
    sum.sort()
    del sum[n-1]
    del sum[0]
    rsum = 0
    for i in range(n-2):
        rsum = rsum + sum[i]
    average = rsum/(n-2)
    result = math.floor(average)
    print(result)

Solution (Python):

from itertools import accumulate
def inpl(): return map(int, input().split())

N = int(input())

while N:
    tmp = sorted([int(input()) for _ in range(N)])
    print(sum(tmp[1:-1])//(N-2))

    N = int(input())

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

Solution (Python):
while 1:
  n=int(input())
  if not n:break
  l=[int(input()) for _ in range(n)]
  l.pop(l.index(max(l)))
  l.pop(l.index(min(l)))
  print(int(sum(l)/len(l)))

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

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

    S = []
    for i in range(n):
        S.append(int(input()))

    S.sort()
    S = S[1:n-1]

    print(sum(S) // len(S))

Solution (Python):

import sys


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)

Solution (Python):
import sys

while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    
    score = []
    for i in xrange(n):
        x = int(sys.stdin.readline())
        
        score.append(x)
    score.sort()
    result = score[1:-1]
    print sum(result) / len(result)

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

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

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

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

Solution (Python):
import sys
if sys.version_info[0]>=3: raw_input=input

def judge(n):
  ma=0
  mi=1000
  s=0
  for i in range(0,n):
    x=int(raw_input())
    if x<mi:
      mi=x
    if x>ma:
      ma=x
    s+=x
  print((s-ma-mi)//(n-2))

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

Solution (Python):
import sys
if sys.version_info[0]>=3: raw_input=input

def judge(n):
  ma=0
  mi=1000
  s=0
  for i in range(0,n):
    x=int(raw_input())
    if x<mi:
      mi=x
    if x>ma:
      ma=x
    s+=x
  print((s-ma-mi)//(n-2))

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

Solution (Python):
while(True):
  n = input()
  if n == 0:
    break;
  sl = 1001
  sh = 0
  ret = 0
  for i in range(n):
    tmp = input()
    ret += tmp
    if tmp < sl:
      sl = tmp
    if tmp > sh:
      sh = tmp
  ret -= (sl + sh)
  print "%d" % (ret/(n-2))

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

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

Solution (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))//(n-2))