
#include<stdio.h>

int main(){

	int n,i,max,min;
	int total;
	int s[100];

	while(1){
		scanf("%d",&n);

		if(n==0){
			break;
		}

		scanf("%d",&s[0]);
		max=min=s[0];

		for(i=1;i<n;i++){
			scanf("%d",&s[i]);
			if(s[i]>max){
				max=s[i];
			}
			if(s[i]<min){
				min=s[i];
			}
		}

		total=0;

		for(i=0;i<n;i++){
			total= total+s[i];
		}
		total-=max;
		total-=min;
		total=total/(n-2);

		printf("%d\n",total);
	}

	return(0);
}