#include <stdio.h>

int main(void) {
	int shinpan_num;
	int now,total,max,min;
	int i;
	while(1) {
		scanf("%d",&shinpan_num);
		if(shinpan_num==0)break;
		total=0;
		max=0;
		min=0x7fffffff;
		for(i=0;i<shinpan_num;i++) {
			scanf("%d",&now);
			if(now>max)max=now;
			if(now<min)min=now;
			total+=now;
		}
		total-=max+min;
		shinpan_num-=2;
		printf("%d\n",total/shinpan_num);
	}
	return 0;
}