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: Accepted

Solution code:
while True:
    n = int(input())
    if n ==0:
        break
    else:
        list0=[]
        i=0
        for i in range(n):
            list0.append(int(input()))    
        list0.remove(max(list0))
        list0.remove(min(list0))
        s=sum(list0)
        a = n-2
        print(s//a)
        i=i+1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    numbers = []

    if n == 0:
        break

    for i in range(0, n):
        numbers.append(int((input())))

    maxValue = max(numbers)
    minValue = min(numbers)
    totalScore = sum(numbers)

    print(str(int((totalScore - maxValue - minValue) / (len(numbers) - 2))))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        a=int(input())
        max=a
        min=a
        sum=a
        for i in range(1,n):
            b=int(input())
            sum=sum+b
            if max<b:
                max=b
            elif min>b:
                min=b
        print(int((sum-max-min)/(n-2)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True:
  n=int(input())
  if n==0:
    break
  m=10000
  M=0
  sum=0
  for i in range(n):
    s=int(input())
    m=min(m,s)
    M=max(M,s)
    sum=sum+s
  print((sum-M-m)//(n-2))

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    m=10000
    M=0
    sum=0
    for i in range(n):
        s=int(input())
        m=min(m,s)
        M=max(M,s)
        sum+=s
    print((sum-M-m)//(n-2))

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n == 0:
        break
    else:
        li1=[0]*n
    
        #t=1
        for t in range(n):  
            li1[t]=int(input())
        s=int((sum(li1)-max(li1)-min(li1))/(n-2))
        print(s)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        score=[0]*n
    for i in range(n):
        score[i]=int(input())
    max=score[0]
    min=score[0]
    for i in range(1,n):
        if max<score[i]:
            max=score[i]
        if min>score[i]:
            min=score[i]
    print(int((sum(score)-max-min)/(n-2)))

Submission status: Accepted

Solution code:
list1=[]
while True: 
    n = int(input())
    if n == 0:
        break #n が 0 のときにループから抜ける
    else:
        for i in range(n):
            j=int(input())
            list1.append(j)
        list1.remove(max(list1))
        list1.remove(min(list1))
        print(sum(list1)//len(list1))
        list1=[]

Submission status: Accepted

Solution code:
while True:
  goukei=0
  max=0
  min=1000

  n=int(input())
  if n==0:
     break
  else:
   for i in range (n):
     i=int(input())
     if i>max:
         max=i
     if i<min:
         min=i
     goukei=goukei+i 
     heikin=(goukei-max-min)//(n-2)
   print(heikin)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0: 
        break
    a, smin, smax=0, 1001, -1
    for i in range(n):
        s = int(input())
        a += s
        if s < smin:
            smin = s
        if s > smax:
            smax = s
        
    print((a-smin-smax)//(n-2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
result = []
while True:
    no_referee = int(input())
    if no_referee == 0:
        break
    else:
        sum_score = 0
        max_score = 0
        min_score = 1000
        for i in range(no_referee):
            score = int(input())
            sum_score += score
            if score > max_score:
                max_score = score
            if score < min_score:
                min_score = score
        sum_score = sum_score - max_score - min_score
        result.append(int(sum_score/(no_referee-2)))

for r in result:
    print(str(r))

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    s=[]
    if n==0:
        break
    else:
        for i in range(n):
            s.append(int(input()))
        s.sort()
        del(s[0])
        del(s[-1])
        
        print(f'{sum(s)//(n-2)}')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#(38)ICP得点集計ソフトウェア
while True:
     n=int(input())
     if n==0:
          break
     s=[int(input()) for i in range(n)]
     a=max(s)
     b=min(s)
     c=sum(s)
     d=(c-a-b)//(n-2)
     print(d)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
while True:
    x=[]
    y=0
    n=int(input())
    if n==0:
        break
    for i in range(n):
        s=int(input())
        x+=[s]
    #print(x)
    
    x.remove(max(x))
    #print(x)
    x.remove(min(x))
    #print(x)
    
    
    for j in range(n-2):
        y+=x[j]
    
    #print(y)
    
    print(
        math.floor(y/(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()
  point = (sum(s)-max(s)-min(s))//(len(s)-2)
  print(point)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# 38
while True: 
    n = int(input())
    S = []
    if n==0:
        break
    for i in range(n):
        S.append(int(input()))
    #print(S)
    S.sort()
    #print(S)
    S.pop(0)
    S.pop()
    #print(S)

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

Submission status: Accepted

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

Submission status: Accepted

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

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)-min(s)-max(s))//(n-2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
while True: #無限に繰り返す
    num = int(input()) #標準入力
    if num == 0:break #入力値が0だった場合繰り返しを強制終了する
    else: #0でなければ
        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)) #リストの平均を出力する

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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