#include <stdio.h>

int main(void) {
	int max, min;
	int n, s[128];
	int i;
	int temp;

	do {
		scanf("%d", &n);
		if(!n)
			break;

		max = 0;
		min = 1000;
		temp = 0;

		for(i = 0; i < n; i++) {
			scanf("%d", &s[i]);
			if(s[i] > max)
				max = s[i];
			if(min > s[i])
				min = s[i];

			temp += s[i];
		}

		printf("%d\n", (temp - max - min) / (n - 2));
	} while(1);

	return 0;
}