#include<stdio.h>
int main(){
	int i, j, max=0, min=1000, sum=0, point;
	while(1){
		scanf("%d", &i);
		if(i == 0)
			break;
		else{
			for(j=0; j<i; j++){
				scanf("%d", &point);
				if(point <= min)
					min = point;
				if(point >= max)
					max = point;
				sum += point;
			}
				printf("%d\n", (sum-max-min)/(i-2));
				min=1000;
				max=0;
				sum=0;
		}
	}
	return 0;
}