#include <stdio.h>
int main(void){
int n, s[105], M, m, S, i;
    n=1;
    while (n!=0) {
        scanf("%d", &n);
        if (n==0) break;
        M=-1; m=1001; S=0;
        for (i=1; i<=n; i++) {
            scanf("%d", &s[i]);
            if (s[i]>M) M=s[i];
            if (s[i]<m) m=s[i];
            S+=s[i];
        }
        printf("%d\n", (S-M-m)/(n-2));
    }
    return 0;
}
