Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

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

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

Python: # coding: utf-8
# Your code here!
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))//(len(a)-2))

Python: #import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

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

Python: # -*- coding: utf-8 -*-
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())

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

Python: list2=[]
while True:
    try:
        N=int(input())
        list1=[int(input()) for _ in range(N)]
        list2.append(int((sum(list1)-max(list1)-min(list1))/(N-2)))
    except:
        break
for tmp in list2:
    print(tmp)

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

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)

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)

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

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

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

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

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

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

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)

Python: while True:
    p=int(input())
    
    if p==0:
        break
    else:
        list1=[]

        for i in range(p):
            a=int(input())
            list1.append(a)
            i+=1

        min1=min(list1)
        max1=max(list1)

        list1.remove(min1)
        list1.remove(max1)

        sum1=sum(list1)

        men=p-2
        print(sum1//men)

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)

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

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

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

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

Python: while True:
    n=int(input())
    if n==0:
        break
    else:
        max_s=0
        min_s=2000
        sum_s=0
        for i in range(n):
            s=int(input())
            sum_s=sum_s+s
            if s<min_s:
                min_s=s
            if s>max_s:
                max_s=s
        print((sum_s-max_s-min_s)//(n-2))

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)

Python: #-*- coding:utf-8 -*-


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

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

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

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

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

Python: def culc(num_referee):
    data=[]
    for i in range(num_referee):
        data.append(int(input()))
    data.sort()
    sum_data=0
    data[0]=0
    data[len(data)-1]=0
    #print(data)
    for j in data:
        sum_data=sum_data+j
    avg=sum_data/(len(data)-2)
    print(int(avg))


num_referee=1
while(1):
    num_referee=input()
    #print(num_referee)
    if num_referee != "0":
        culc(int(num_referee))
    else:
        break