
#include <stdio.h>
 
int main(void){

	int n, i, j,  min, max, sum;

	while( scanf("%d", &n ) != EOF ) {
		if( !n ) break;
		min = 1000;
		sum = 0;
		max = 0;
		for( i = 0; i < n; i++ ) {
			scanf("%d", &j );
			if( j < min )
				min = j;
			if( j > max )
				max = j;
			sum += j;
		}
		printf("%d\n", (sum - max - min)/(n-2) );
	}

	return 0;
}