

#include <stdio.h> 
int main(void){ 
int n,i,s,min,max,ave; 
int sum = 0; 
 
while(1){
 
scanf("%d",&n); 
scanf("%d",&s);

if(n==0)
break;

sum = s; 
max = s; 
min = s; 
for (i = 2;i <= n;i++){ 
    scanf("%d",&s); 
    sum += s; 
    if(s>max) 
    max = s; 
    if(s<min) 
    min = s; 
   
   ave = (sum-min-max)/(n-2); 
} 
printf("%d\n",ave); 
}
return 0; 
    
} 

