#include <stdio.h>

int main(void) {
	int score, judge, point;
	int i, sum, max, min;
	while(scanf("%d", &judge) && judge) {
		sum = 0;
		max = 0;
		min = 1000;
		for(i = 0; i < judge; i++) {
			scanf("%d", &point);
			sum += point;
			max = (max < point) ? point : max;
			min = (min > point) ? point : min;
		}
		score = sum - min - max;
		score /= (judge - 2);
		printf("%d\n", score);
	}
	return 0;
}