#include <stdio.h>


int main () {

	int dataset=0;
	int count=0;

	int point[1000]={};
	int max=0;
	int sma=0;
	int cul=0;


	


	while(1){

		scanf("%d",&dataset);

		if(dataset ==0){
			break;
		}

		
		count=0;
		for ( count=0; count < dataset; count++){
				scanf("%d",&point[count]);
				if(count==0){
					max = point[count];
					sma = point[count];
				}
				if(max < point[count]){
					max = point[count];
				}
				if(sma > point[count]){
					sma = point[count];
				}
				cul += point[count];


		}		
		cul -= max;
		cul -= sma;
		cul = cul/(dataset-2);
		printf("%d\n",cul );
		max=0;
		sma=0;
		cul=0;

		
	}
		


	return 0;
}