#include<stdio.h>

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