#include <stdio.h>

int main(void){

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

	return 0;
}