#include <stdio.h>

int main(){
    int i,j,n[i],s[i],t,a,b,r[i];
    
    i=0;
    while (1) {
        scanf("%d",&n[i]);
        if (n[i]==0) break;
        t=0;
        a=0;
        b=1000;
        for (j=0;j<n[i];j++) {
            scanf("%d",&s[j]);
            t+=s[j];
            if (a<s[j]) {a=s[j];}
            if (b>s[j]) {b=s[j];}
        }
        r[i]=t-a-b;
        
    }
    for (j=0;j<i;j++) {
        printf("%d\n",(r[j]/(n[j]-2)));
    }
    
    return 0;
    
}