#include<stdio.h>
int main(void){
	
	int n,s,a[100],max,min,sum,ave,ave1[20],k,l,m;
	
	l=1;
	
	while(1){
		
		scanf("%d",&n);
		sum=0;
		
		if(n==0)break;
		
		for(k=1;k<=n;k++){
			
			scanf("%d",&s);
			
			a[k]=s;
			
			if(k==1){
				max=a[1];
				min=a[1];
			}
			
			if(a[k]>max){
				max=a[k];
			}
			if(a[k]<min){
				min=a[k];
			}
			
			sum=sum+a[k];
			
		}
		
		ave=(sum-max-min)/(n-2);
/*		
		printf("max%d,min%d\n",max,min);
		printf("sum%d,ave%d\n",sum,ave);
*/		
//		printf("%d\n",ave);
		
		ave1[l]=ave;
		
		l++;
	}
	
	for(m=1;m<l;m++){
		printf("%d\n",ave1[m]);
	}
	
	return 0;
}
