#include <stdio.h>

int main( void ) {

	int n, i, s[100], max = 0, min = 1000, sum = 0;

	while ( scanf( "%d", &n ) && n > 0 ) {

		for ( i = 0; i < n; i++ ) {

			scanf( "%d", &s[i] );

			if ( s[i] > max ) { max = s[i]; }
			if ( s[i] < min ) { min = s[i]; }

			sum += s[i];

		}

		printf( "%d\n", ( sum - max - min ) / ( n - 2 ) );

	}

	return 0;

}