#include <stdio.h>

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