#include <stdio.h>
int main(void){
    int n;
    while(1){
        scanf("%d",&n);
        int sum=0,ad,max=0,min=1000,suma;
        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;
}
