#include <stdio.h>

int main( void ) {
	int i, n, sum, min, max, tmp;

	for ( ; scanf( "%d", &n ), n; printf( "%d\n", ( sum - min - max ) / ( n - 2 ) ) ) {
		max = sum = 0;
		min = 1000;
		for ( i = n; i--; sum += tmp ) {
			scanf( "%d", &tmp );

			if ( tmp < min )
				min = tmp;
			if ( max < tmp )
				max = tmp;
		}
	}

	return 0;
}