#include <stdio.h>

int main(void){
	int n, s, i, j, sum, max, min;

	for (i = 0; i < 20; i++){
		scanf("%d", &n);
		if (n == 0) break;
		else if (2 < n && n < 101){
			max = 0; min = 1000; sum = 0;
			for (j = 0; j < n; j++){
				scanf("%d", &s);
				if (s >= 0 && s <= 1000){
					if (s > max) max = s;
					else if (s < min) min = s;
					sum += s;
				}
			}
			sum = sum - max - min;
			printf("%d\n", sum / (n - 2));
		}
	}
	return 0;
}