#include <stdio.h>
int main(void)
{
	int n,sum=0,max=0,min=1000,ad,suma=0;

	while(1){
        scanf("%d",&n);
        if(n==0) break;
        for(int i=0;i<n;i++){
            int s[n];
    		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;
}
