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):
n=int(input())
while n!=0:
    total=0
    saidai=None
    saishou=None
    for i in range(n):
        s=int(input())
        total+=s
        if saidai is None or s>saidai:
            saidai=s
        if saishou is None or s<saishou:
            saishou=s
    print((total-saidai-saishou)//(n-2))        
    n=int(input())

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

Solution (Python):
while True:
    n = int(input())
    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)
        b.pop(0)
        s=sum(b) 
        ave= s/(n-2)
        print(int(ave))

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

Solution (Python):
import math
while True:
    x = int(input())
    if x == 0:
        break
    a = list(int(input()) for i in range(x))
    
    a.sort()
    del a[0]
    del a[-1]
    
    b= sum(a)/len(a)
    print(math.floor(b))

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

Solution (Python):
while True:
    n = int(input())
    str_list = [int(input()) for _ in range(n)]
    if n==0:
        break
    a = max(str_list)
    b = min(str_list)
    c = sum(str_list)
    tensu = (c-a-b)//(n-2)
    print(tensu)

Solution (Python):
while True:
    n=int(input())
    if n==0:break
    s,vmax,vmin = 0,-1,1001
    for i in range(n):
        a = int(input())
        vmax=max(vmax,a)
        vmin=min(vmin,a)
        s+=a
    print((s-vmax-vmin)//(n-2))

Solution (Python):
while True:
    n=int(input())
    if n == 0 : break
    a,b,c=0,1001,-1
    for i in range(n):
        m=int(input())
        b=min(b,m)
        c=max(c,m)
        a+=m
    print((a-b-c)//(n-2))

Solution (Python):



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

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

    nums = [int(input()) for _ in range(n)]
    max_num = max(nums)
    min_num = min(nums)
    nums.remove(max_num)
    nums.remove(min_num)
    print(sum(nums) // len(nums))

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

Solution (Python):
while True :
    n=int(input())
    if n==0:break
    ssum=0
    smax=0
    smin=1000
    for i in range(n):
        s=int(input())
        ssum+=s
        if smax<s : smax=s
        if smin>s : smin=s
    print((ssum-smax-smin)//(n-2))

Solution (Python):
while True:
    n = int(input())
    if n > 0:
        l = []
        for i in range(n):
            s = int(input())
        
            l.append(s)
        l.remove(max(l))
        l.remove(min(l))
        x = sum(l)
        y = len(l)
        print(int(x/y))
    if n == 0:
        break

Solution (Python):
a=int(input())
while a!=0:
    M=0
    m=1000
    sam=0
    for i in range(a):
        b=int(input())
        sam+=b
        M=max(M,b)
        m=min(m,b)
    print(int((sam-M-m)/(a-2)))
    a=int(input())

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

Solution (Python):
for x in range(20):
    a=int(input())
    if a==0: break
    
    lst = []
    for x in range(a):
        lst.append(int(input()))
    b=min(lst)
    c=max(lst)
    lst.remove(b)
    lst.remove(c)
    d=sum(lst)
    ave=d//(a-2)
    print(ave)

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

Solution (Python):

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

Solution (Python):
while True:
    n=int(input())
    if n==0:
        break
    s=0
    vmin=1001
    vmax=-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 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):
while True:
    n=int(input())
    x=[]
    if n==0:
        break
    else:
        for i in range(n):
            s=int(input())
            x.append(s)
        a=min(x)
        b=max(x)
        ave=(sum(x)-a-b)/(n-2)
        print(int(ave))

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

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

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

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

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

Solution (Python):
while True:
    A = int(int(input()))
    if A == 0:
        break
    a = [int(input()) for i in range(A)]

    x = min(a)
    y = max(a)
    z = (sum(a) - x - y)//(A-2)

    print(z)

Solution (Python):
while True:
  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):
while True:
    n=int(input())
    if n==0:
        break
    i,min,max,a=0,1000,0,0
    while i<n:
        s=int(input())
        a+=s
        if min>s:
            min=s
        if max<s:
            max=s
        i+=1
    print((a-min-max)//(n-2))

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

Solution (Python):
import math
while True:
    x=[]
    y=0
    n=int(input())
    if n==0:
        break
    for i in range(n):
        s=int(input())
        x+=[s]
    
    
    x.remove(max(x))
    
    x.remove(min(x))
    
    
    
    for j in range(n-2):
        y+=x[j]
    
    
    
    print(
        math.floor(y/(n-2))
        )

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

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

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

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

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

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    tensu = []
    for i in range(1,n+1):
        s = int(input())
        tensu.append(s)
    m = min(tensu)
    M = max(tensu)
    tensu.remove(m)
    tensu.remove(M)
    t = len(tensu)
    sum = 0
    for j in range(0,t):
        sum += tensu[j]
    r = sum // t
    print(r)

Solution (Python):
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=[int(input()) for i in range(n)]
        x=max(a)
        y=min(a)
        a.remove(x)
        a.remove(y)
        ave = sum(a)//len(a)
        print(ave)

Solution (Python):

while True:
    n=int(input())
    m,smin,smax=0,1000,-1
    if n==0:break
    for i in range(n):
        s=int(input())
        smin=min(smin,s)
        smax=max(smax,s)
        m += s
    print((m-smin-smax)//(n-2))

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

Solution (Python):
while True :
    
    n=int(input())
    if n==0 :
        break
    
    i=0
    b=0
    ma=0
    mi=1000
    while i<n :
        c=int(input())
        if ma<c :
            ma=c
        if mi>c :
            mi=c
        b=b+c
        i=i+1
    print(int((b-ma-mi)/(n-2)))

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

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

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

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

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

    x = 0
    b = -1
    c = 1001
    for i in range(n):
        a = int(input())
        x += a
        b = max(b, a)
        c = min(a, c)
        y = (x-b-c)//(n-2)
        
    i += 1

    print(y)

Solution (Python):


while True: 
    n = int(input())
    S = []
    if n==0:
        break
    for i in range(n):
        S.append(int(input()))
    
    S.sort()
    
    S.pop(0)
    S.pop()
    

    print(sum(S)//(n-2))

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

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

for i in ans:
    print(i)

Solution (Python):
while True:
    n = int(input())
    max = 0
    min = 1000
    sum = 0
    ave = 0
    if n == 0:
        break
    for i in range(n):
        s = int(input())
        sum += s
        if s < min:
            min = s
        if max < s:
            max = s
    ave = (sum - min - max) // (n - 2)
    print(ave)

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

    s=[int(input()) for i in range(n)]
    print((sum(s)-min(s)-max(s))//(n-2))

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

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

Solution (Python):
while True:
    n=int(input())
    
    x=[]
    for i in range(n):
        s=int(input())
        x.append(s)
    x1=sorted(x)
    if n==0:
        break
    else:
        sum1=sum(x1)
        sum1-=x1[0]+x1[n-1]
        y=sum1//(n-2)
        print(y)

Solution (Python):
p=1
num=[]
while p==1:
    x=int(input())
    if x==0:
        break
    else:
        y=x
        while y>0:
            a=int(input())
            num.append(a)
            y-=1
        num.sort()
        del num[0]
        del num[-1]
        poo=sum(num)
        pooh=poo//(x-2)
        print(pooh)
        num.clear()

Solution (Python):
while True :
    n=int(input())
    if n==0:
        break
    su,amin,amax=0,1000,0
    for i in range(n):
        a=int(input())
        amin=min(amin,a)
        amax=max(amax,a)
        su+=a
    print((su-amin-amax)//(n-2))

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

Solution (Python):
while True:
    
    amax=-1; amin=1001; t=0
    n = int(input())
    if n==0:
        break
    
    for i in range(n):
        a = int(input())
        amax = max(amax,a)
        amin = min(amin,a)
        t += a
    
    print((t-amax-amin)//(n-2))

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

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

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

Solution (Python):
while True:
    n=int(input())
    if n==0:
        break
    i=1
    sum=0
    max=0
    min=1000
    while i<=n:
        a=int(input())
        if max<a:
            max=a
        if min>a:
            min=a
        sum+=a
        
        
        i+=1
    sum=sum-max-min
    print(int(sum/(n-2)))

Solution (Python):



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

Solution (Python):
while True:
    n=int(input())
    max=0
    min=1000
    sum=0
    ave=0
    if n==0:
        break
    for i in range(n):
        s=int(input())
        sum+=s
        if s<min:
            min=s
        if max<s:
            max=s
    ave=(sum-min-max)//(n-2)
    print(ave)

Solution (Python):
while True: 
    num = int(input()) 
    if num == 0:break 
    else: 
        num_list = [] 
        for _ in range(num): 
            num_list.append(int(input())) 
        num_list.sort() 
        num_list.pop(-1) 
        num_list.pop(0) 
        num = sum(num_list) 
        num1 = len(num_list) 
        print(int(num / num1))

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

Solution (Python):
while True:
    n=int(input())
    if n==0:
        break
    s=0
    y=[]
    for i in range(1,n+1):
        a=int(input())
        y.append(a)
    ymax=max(y)
    ymin=min(y)
    y.remove(ymax)
    y.remove(ymin)
    ysum=sum(y)
    print(int(ysum/(n-2)))

Solution (Python):
while True :
    n = int(input())
    P = []
    
    if n == 0 :
        break
    else :
        for i in range(n) :
            P.append(int(input()))
        
        Ps = sorted(P)
        del Ps[0]
        del Ps[n - 2]
        s = sum(Ps)
        
        print(s // (n - 2))

Solution (Python):
from pprint import pprint as pp
from pprint import pformat as pf
import math

def get_data():
    input_data = int(input())
    return input_data

def make_score_list(referee_num):
    score_list = [None] * referee_num
    for i in range(referee_num):
        score_list[i] = get_data()
    return score_list

def calculate_adjusted_average(score_list, referee_num):
    referee_num -= 2
    adjusted_average = (sum(score_list) - max(score_list) - min(score_list)) / referee_num
    return adjusted_average


if __name__ == "__main__":
    while True:
        referee_num = get_data()
        if referee_num == 0:
            break
        score_list = make_score_list(referee_num)
        adjusted_average = math.floor(calculate_adjusted_average(score_list, referee_num))
        print(adjusted_average)

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

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

Solution (Python):
while 1:
    n = int(input())
    if n == 0:
        break
    point = [int(input()) for i in range(n)]
    point.sort()
    Sum = 0
    hito = 0
    for i in range(1,n-1):
        Sum += point[i]
        hito += 1
    ans = Sum // hito
    print(ans)

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

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

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

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

Solution (Python):
def main():
    N = int(input())
    while N != 0:
        s = [int(input()) for i in range(N)]
        s.sort()
        print(sum(s[1:N-1])//(N-2))
        N = int(input())
if __name__ == '__main__':
    main()

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

    for i in range(n):
        judges.append(int(input()))

    print((sum(judges) - max(judges) - min(judges)) // (len(judges) - 2))

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

Solution (Python):





from sys import stdin,setrecursionlimit


setrecursionlimit(10**6)
input=stdin.readline

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

Solution (Python):



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

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

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

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

Solution (Python):
from math import *

while True:
    a = int(input())
    if a == 0: break

    
    score_list = []
    
    
    for i in range(a):
        score_list.append(int(input()))
    
    max_ = max(score_list)
    min_ = min(score_list)

    
    ans_list = []
    flag = 0
    for score in score_list:
        if score == max_ and not flag:
            flag = 1
            continue
        else:
            ans_list.append(score)

    new_ans_list = []
    flag = 0
    for score in ans_list:
        if score == min_ and not flag:
            flag = 1
            continue
        else:
            new_ans_list.append(score)

    avg = sum(new_ans_list)/len(new_ans_list)
    print(int(avg))

Solution (Python):


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

Solution (Python):
def solve(n, score):
    score = sorted(score)
    return sum(score[1:-1])//len(score[1:-1])

def main():
    ans = []
    while True:
        n = int(input())
        if (n == 0):
            break
        score = [int(input()) for i in range(n)]
        ans.append(solve(n, score))
    
    for i in ans:
        print(i)

main()

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

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(sum(s)//len(s))

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

Solution (Python):






import sys
import math
import array


class mymath:
    
    pi = 3.14159265358979323846264338

    
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()


class output:
    
    def list(self, l):
        l = list(l)
        
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

















def main():
    ans = []
    while(True):
        N = int(input())
        point = []

        if N == 0:
            break

        for i in range(N):
            point.append(int(input()))
    
        pointsum = sum(point)-(max(point)+min(point))

        ans.append(pointsum//(N-2))
        
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

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

Solution (Python):
while True:
    n = int(input())
    if n == 0:
        break
    sum_ = 0
    max_ = 0
    min_ = 1000
    for i in range(n):
        tmp = int(input())
        sum_ += tmp
        max_ = max(max_, tmp)
        min_ = min(min_, tmp)
    sum_ -= max_
    sum_ -= min_
    print(int(sum_/(n-2)))

Solution (Python):
def solve(n):
    a = [int(input()) for i in range(n)]
    print((sum(a)-max(a)-min(a))//(n-2))


while(True):
    n = int(input())
    if(n == 0):
        quit()
    solve(n)

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    while True:
        n = II()
        if not n:
            break
        a = IR(n)
        a.sort()
        print(sum(a[1:-1])//(n-2))
            
    return


def B():
    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    A()

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

Solution (Python):
N = int(input())
while N != 0:
        total = 0
        minimam = 1000
        maximam = 0
        for _ in range(N):
                s = int(input())
                total += s
                minimam = min(minimam, s)
                maximam = max(maximam, s)
        print(int((total-minimam-maximam)/(N-2)))
        N = int(input())

Solution (Python):
Ps = []

while True:
    i = int(input())
    if i == 0:
        break
    P = []
    P.append(i)
    for ii in range(i):
        P.append(int(input()))

    Ps.append(P)

for p in Ps:
    p[0] = 0
    p.sort()
    p[1] = 0
    p[-1] = 0
    print(int(sum(p) / (len(p) - 3)))