#include <stdio.h>

int main(void) {
	int n,i,max=0,min=1000,ad;
	int s[100];
	long long int sum=0,suma;
	for(i=0;i<n;i++){
		while(1){
			scanf("%d",&n);
			if(n==0) break;
			scanf("%d",&s[i]);
			sum=sum+s[i];
			if(s[i]>max) max=s[i];
			if(s[i]<min) min=s[i];
			suma=sum-(max+min);
			ad=suma/(n-2);
			printf("%d\n",ad);
		}
	}
	return 0;
}
