#include <stdio.h>

int main(void) {
    int i,n,max,min,s,s_ans,total;
    int count = 0;
    
    while(count<=20){
        total = 0;
        max = 0;
        min = 1000;
        
        scanf("%d",&n);
        if(n==0)
            break;
        
        for(i=0;i<n;i++){
            scanf("%d",&s);
            total+=s;
            if(s>max)
                max = s;
            if(s<min)
                min = s;
        }
        s_ans = (total-max-min) / (n-2);
        printf("%d\n",s_ans);
        count++;
    }
    return 0;
}