#include <stdio.h>

int main(void) {

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

