#include <stdio.h>

int main(){
	int n;
	int a[100] = {0};
	int i, j;
	int sum;
	int p, q;

while(1){
	scanf("%d", &n);
	sum = 0;
	if(n == 0) break;
	for (i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
		sum += a[i];
	}
	p = a[0];
	q = a[0];
	for (i = 1; i < n; ++i)
	{
		if(p < a[i]) p = a[i];  
		if(q > a[i]) q = a[i];
	}

	sum = sum - p - q;

	printf("%d\n", sum / (n - 2));
}
	return 0;
}