#include <stdio.h>

int main(void) {
	int n,sum,j,i,s[100],max,min;
	max = 1001;
	min = -1;
	sum = 0;

	while(1){
		scanf("%d",&n);
		if(n == 0)
			break;
		for(i=0;i<n;i++){
			scanf("%d",&s[i]);
			 if(max==1001)max=s[i];
			 if(min==-1)min=s[i];
			if(max < s[i]) max = s[i];
			else if(min > s[i]) min = s[i];
			sum += s[i];
		}	
	
		sum -= max;
		sum -= min;
		printf("%d\n",sum/(n-2));
	}
	
	return 0;
}

