# include <stdio.h>

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