#include <stdio.h>
int main(void){
    // Here your code !
    int P,N,i,sum=0;
    int max=0,min=1000;
    while(1){
        sum=0;max=0;min=1000;
        scanf("%d",&N);
        if(N==0)break;
        for(i=0;i<N;i++){
            scanf("%d",&P);
            if(P>max)max=P;
            if(P<min)min=P;
            sum+=P;
        }
        printf("%d\n",(sum-max-min)/(N-2));
    }
    return 0;
}