#include<stdio.h>

int main()
{
	int i, n, min, max, score, total;
	
	while(1)
	{
		scanf("%d", &n);
		
		if(n == 0) break;
		
		total = 0;
		max = 0;
		min = 1000;
		
		for(i = 0; i < n; i++)
		{
			scanf("%d", &score);
			
			if(score > max)
				max = score;
			
			if(score < min)
				min = score;
			
			total += score;
		}
		
		total -= (max + min);
		
		printf("%d\n", total / (n - 2));
	}
	
	return 0;
}