#include <stdio.h>
#include <math.h>



int main(){
	int n,s[110];
	int i,j,k,l,m;
	int max,min;
	int sum;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		max=-1;
		min=-1;
		sum=0;
		for(i=0; i<n; i++){
			scanf("%d",&s[i]);
			if(max==-1)max=s[i];
			if(min==-1)min=s[i];
			if(max<s[i])max=s[i];
			if(min>s[i])min=s[i];
			sum+=s[i];
		}
		sum-=max;
		sum-=min;
		printf("%d\n",sum/(n-2));
	}

	return 0;
}