#include <stdio.h>

int main() {

	int i, j = 0, n, min[100], max[100], sum[100] = {0};
	int point[1000], ans[100];

	while (true) {
		scanf("%d", &n);

		if (n == 0)
			break;

		for (i = 0; i < n; i++) {
			scanf("%d", &point[i]);
		}

		min[j] = point[0];
		max[j] = point[0];

		for (i = 0; i < n; i++) {
			if (max[j] < point[i]) {
				max[j] = point[i];
			}
			if (min[j] > point[i]) {
				min[j] = point[i];
			}
			sum[j] += point[i];
		}
		ans[j] = (sum[j] - min[j] - max[j])/(n-2);
		j++;
	}

	
	for(i = 0;i < j; i++){
		printf("%d\n",ans[i]);
	}
	

	return 0;
}