#include <stdio.h>
 
int main(void)
{
    int n;
 
    while(1){
        scanf("%d", &n);
        if(!n)
        break;
        
        
        int point[128] = {0};
        int max = 0;
        int min = 1000;
        int i=0;
        int j=0;
        int k=0;
        int x=0;
        i = n;
        while(i-- > 0){
           scanf("%d",&x);
          
           if(x>max){
           point[j] = max;
           max = x;
           j++;
           }
           else if(x<min){
           point[j] = min;
           min = x; 
           j++;
           }
           //if(min < x && max > x)
           else{
           point[j] = x;
           j++;
           }
        }
        int sum = 0;
        for(j=0;j<n+2;j++)
            sum = sum + point[j];
            
        sum = sum-1000;
        printf("%d\n", sum/(n-2));
    }
 
    return 0;
}