#include <stdio.h>
#include <stdlib.h>

int cmp(int *x, int *y)
{
	return (*x - *y);
}

int main(int argc, char const *argv[])
{
	int scores[1024];
	int n;

	while (scanf("%d", &n), n){
		int i;
		int sum = 0;

		for (i = 0; i < n; i++){
			scanf("%d", scores + i);
		}
		qsort(scores, n, 4, cmp);

		for (i = 1; i < n - 1; i++){
			sum += scores[i];
		}
		printf("%d\n", sum / (n - 2));
	}
	return 0;
}