#include<stdio.h>
#include<math.h>
#define MAX 1000

int main(void){
	
	int i,n,max,min,sum,a[1000],t;
	
	while(t != 1){

scanf("%d",&n);

if(n != 0){
	for(i = 0 ; i < n ; i++){
		a[i] = 0;
	}
	sum = 0;
	for(i = 0 ; i < n ; i++){
	scanf("%d",&a[i]);
	sum = sum + a[i];
	}
	max = a[0];
	for(i = 0 ; i < n ; i++){
		if(max < a[i]){
			max = a[i];
		}
	}
	
	min = a[0];
	for(i = 0 ; i < n ; i++){
		if(min > a[i]){
		min = a[i];
		}
	}
	
	sum = sum - max - min;
	
	n = n - 2;
	printf("%d\n",sum/n);
	
}
if(n == 0){
t = 1;
}
}
return 0;
}