#include <stdio.h>

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