#include<stdio.h>

int main(){
	int judgment,point,point_sum=0,point_max=0,point_min=1000,i;

	while(1){
		scanf("%d",&judgment);
		
		if(judgment==0)break;

		for(i=0;i<judgment;i++){
			scanf("%d",&point);
			point_sum+=point;
			if(point>point_max)
				point_max=point;
			if(point<point_min)
				point_min=point;
		}
		point_sum=point_sum-point_max-point_min;

		printf("%d\n",point_sum/(judgment-2));
		point_sum=0;
		point_max=0;
		point_min=1000;
	}

	return 0;
}