#include <stdio.h>

int getfinalscore (int,int scores[]);

int main (void)
{
	int i=0,j=0,k=0;
	int n[20];
	int s[20][100];
	int finalscore[20];

	for(i=0;;i++){
		scanf("%d",&n[i]);
		if(n[i]==0) break;

		for(j=0;j<n[i];j++){
			scanf("%d", &s[i][j]);
		}
	}
		
	/*i?????????????????§???performance?????°?????????*/
	/*j??????????????????*/

	for(k=0;k<i;k++){
		finalscore[k]=getfinalscore(n[k],s[k]);
		printf("%d\n", finalscore[k]);
	}

	return 0;
}

int getfinalscore (int judges,int scores[])
{
	int max=0,min=1000,sum=0,average,m;
	
	for(m=0;m<judges;m++){ /*m??????????????????*/
		sum+=scores[m];
		if(scores[m]>max){
			max=scores[m];
		}
		if(scores[m]<min){
			min=scores[m];
		}
	}

	average=(sum-max-min)/(judges-2);

	return average;
}