#include <stdio.h>

int main(void) {
	int n,count,j,i,s[100],temp;
	count = 0;

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

