#include <stdio.h>

int main(void){

	int Max,Min,n,i,k,S,Count;
	
	int dataset[20];
	
	Count = 0;
	
	for(k=0;k<=19;k++){
	
		scanf ("%d",&n);
		
		if(n == 0){
			
			break;
			
		}
		
		int numbers[100];
		
		
		for(i=0;i<=n-1;i++){
		
			scanf ("%d",&numbers[i]);
			
			if(i == 0){
			
				Max = numbers[i];
				
				Min = numbers[i];
				
				S = numbers[i];
				
			}else if(i != 0){
				
				S = S + numbers[i];
			
				if(numbers[i] < Min){
				
					Min = numbers[i];
					
				}else if(numbers[i] > Max){
				
					Max = numbers[i];
					
				}
				
			}
			
		}
		
	dataset[k] = (S - Max - Min)/ (n - 2);
		
	Count++;
		
			
	}
	
	int l;
	
	for(l=0;l<Count;l++){
		
		printf ("%d\n",dataset[l]);
		
	}
	
	return 0;
	
}

