<image>

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.

Example

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

342
7
300
326

Difficulty: UNKNOWN_DIFFICULTY

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


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


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


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


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


while 1:
	n = int(input())
	if n == 0:
		break
	pt = []
	for _ in range(n):
		pt.append(int(input()))
	pt.sort()
	pt.pop(0)
	pt.pop()
	ans = int(sum(pt) / len(pt))
	print(ans)


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)


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


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


while True:
	n = int(input())
	if n < 3:
		break
	lst = [int(input()) for i in range(n)]
	a = sum(lst)
	b = min(lst)
	c = max(lst)
	avg = (a - b - c) // (n - 2)
	print(avg)


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


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


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


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


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


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


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


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


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)


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


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)


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


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


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


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


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)


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


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)


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


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)


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


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)


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)


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


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


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


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)


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)


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


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


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


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


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


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


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


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


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)


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


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)


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)


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


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)


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


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


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


a = []
i = 0
while True:
	N = int(input())
	if N == 0:
		break
	else:
		for i in range(N):
			n = int(input())
			a.append(n)
		a.sort()
		a.pop()
		a.pop(0)
		print(sum(a) // len(a))
		a.clear()


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


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)


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


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)


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)


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


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


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


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)


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


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


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


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


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)


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


while True:
	a = int(input())
	if a == 0:
		break
	else:
		li = [0] * a
		for i in range(a):
			li[i] = int(input())
		li_sort = sorted(li)
		del li_sort[0]
		del li_sort[-1]
		print(int(sum(li_sort) / len(li_sort)))


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)


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


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)


import math
while True:
	n = int(input())
	scores = [int(input()) for i in range(n)]
	scores.sort()
	if n == 0:
		break
	total = 0
	for i in range(1, n - 1):
		total += scores[i]
	print(math.floor(total / (n - 2)))


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


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


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


from statistics import mean
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(int(mean(S)))


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)


import math
for i in range(30):
	n = int(input())
	if n == 0:
		break
	else:
		ls = []
		for i in range(n):
			ls.append(int(input()))
		ls.sort()
		ls.remove(ls[0])
		ls.remove(ls[-1])
		print(math.floor(sum(ls) / len(ls)))


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


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)


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


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


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


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


while True:
	n = int(input())
	if n == 0:
		break
	b = []
	for i in range(n):
		a = int(input())
		b.append(a)
	c = sorted(b)
	if n == 3:
		print(c[1])
	elif n >= 4:
		d = sum(c) - c[0] - c[n - 1]
		e = n - 2
		print(d // e)


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


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


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


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


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


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)


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]


while True:
	n = int(input())
	score = []
	ans = 0
	if n == 0:
		break
	for i in range(n):
		score.append(int(input()))
	score.sort()
	for i in range(1, len(score) - 1):
		ans += score[i]
	print(ans // (n - 2))


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


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


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)


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


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)


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)


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


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


while True:
	N = int(input())
	if N == 0:
		break
	S = []
	for _ in range(N):
		S.append(int(input()))
	S.sort()
	S = S[1:N - 1]
	ans = sum(S) // len(S)
	print(ans)


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


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


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)


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


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


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


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


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


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


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


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


from statistics import mean
import math
while True:
	n = int(input())
	if n == 0:
		break
	s = [int(input()) for _ in range(n)]
	s.remove(max(s))
	s.remove(min(s))
	print(math.floor(mean(s)))


def calc_score(list):
	list.remove(max(list))
	list.remove(min(list))
	return int(sum(list) / len(list))
while True:
	grader = int(input())
	if grader == 0:
		break
	scores = [int(input()) for _ in range(grader)]
	print(calc_score(scores))


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


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


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


for i in range(20):
	n = int(input())
	if n == 0:
		break
	data = list()
	for j in range(n):
		a = int(input())
		data.extend([a])
	x = sum(data) - min(data) - max(data)
	print(x // (n - 2))


x = []
while True:
	n = int(input())
	if n == 0:
		break
	else:
		for i in range(n):
			s = int(input())
			x.append(s)
		S1 = sum(x) - max(x) - min(x)
		S2 = n - 2
		print(int(S1 / S2))
		x.clear()


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


s = []
while True:
	N = int(input())
	if N == 0:
		break
	else:
		tmp = [int(input()) for _ in range(N)]
		tmp.sort()
		tmp = tmp[1:-1]
		s.append(tmp)
for si in s:
	N = len(si)
	ans = 0
	for sij in si:
		ans += sij
	ans //= N
	print(ans)


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


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


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


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


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


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


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


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


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


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


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


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


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


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)


while True:
	n = int(input())
	if n == 0:
		break
	l = []
	s = 0
	for i in range(n):
		j = int(input())
		l.append(j)
		s += j
	print((s - max(l) - min(l)) // (n - 2))


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


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


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


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


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)


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


while True:
	N = int(input())
	if N == 0:
		break
	L = []
	for i in range(N):
		L.append(int(input()))
	L.sort()
	A = sum(L)
	print((A - L[0] - L[len(L) - 1]) // (N - 2))


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


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


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


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


n = 1
while n != 0:
	n = int(input())
	S = []
	S = [int(input()) for _ in range(n)]
	if n == 0:
		break
	ans = (sum(S) - min(S) - max(S)) / (n - 2)
	Ans = int(ans)
	print(Ans)


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]


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)


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))
	if n == 0:
		break


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


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


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


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


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


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


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


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)


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


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


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


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


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)


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


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


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


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


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


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


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


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


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


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


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


while True:
	mylist = []
	n = input()
	n = int(n)
	if n == 0:
		break
	for i in range(0, n):
		mylist.append(int(input()))
	mylistz = sorted(mylist)
	del mylistz[0]
	del mylistz[n - 2]
	print(int(sum(mylistz)) // (n - 2))


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


while True:
	x = int(input())
	if x == 0:
		break
	a = []
	for i in range(x):
		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)


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


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


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


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


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


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


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)


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


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)


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


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


while True:
	P = []
	n = int(input())
	if n == 0:
		exit()
	for i in range(n):
		P.append(int(input()))
	print(sum(sorted(P)[1:-1]) // (n - 2))


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


while True:
	n = int(input())
	if n == 0:
		break
	else:
		A = []
		i = 1
		while i <= n:
			a = int(input())
			A.append(a)
			i = i + 1
		b = (sum(A) - max(A) - min(A)) // (n - 2)
		print(b)


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


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