#include <stdio.h>

int main(void) {
	int k=0;
	
	while(1){
		
		
		int n, a[111], i, min, max, sum;
		
		scanf("%d", &n);
		
		if(n==0)
		break;
		
		if(k!=0)
		putchar('\n');
		
		scanf("%d", &a[0]);
		sum=a[0];
		max=a[0];
		min=a[0];
		for(i=1;i<n;i++){
			scanf("%d", &a[i]);
			sum+=a[i];
			if(max<a[i])
			max=a[i];
			if(min>a[i])
			min=a[i];
		}
		
		printf("%d", (sum-max-min)/(n-2));
		
		k++;
	}
	return 0;
}