#include <stdio.h>

int main(void){
	int n, max, min, sum, s;
	while(1){
		scanf("%d", &n);
		if(n == 0)break;

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