#include <stdio.h>

int main(){
	int count;
	while(1){
		scanf("%d",&count);
		if(count==0){
			break;
		}
		int counter=0;
		int min=1001,max=-1;
		int i;
		int sum=0;
		while(counter<count){
			scanf("%d",&i);
			if(min>i){
				min=i;
			}
			if(max<i){
				max=i;
			}
			sum+=i;
			counter++;
		}
		sum-=(min+max);
		printf("%d\n",sum/(count-2));
		
	}
	return 0;
}