#include <stdio.h>

int main(void) {
	int n,sum,j,i,s,max,min;
	max = -1;
	min = 1001;
	sum = 0;

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

