// Aizu 1147: ICPC Score Totalizer Software
// 2017.9.13 bal4u@uu

#include <stdio.h>

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

	while (scanf("%d", &n) && n) {
		for (min = 1001, max = -1, sum = 0, i = 0; i < n; i++) {
			scanf("%d", &a);
			if (a < min) min = a;
			if (a > max) max = a;
			sum += a;
		}
		printf("%d\n", (sum - min - max)/(n-2));
	}
	return 0;
}