#include <stdio.h>

int main(void)
{

	int n, i, s;
	int sum = 0, min = 1000, max = 0;

	scanf("%d", &n);
	while(n != 0){
		for(i = 0; i < n; i++){
			scanf("%d", &s);
			sum += s;
			if(s < min)
				min = s;
			if(s > max)
				max = s;
		}
		sum = (sum - min - max) / (n-2);
		printf("%d\n", sum);
		scanf("%d", &n);
	}

	return 0;
}

