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