#include <stdio.h>
#include <stdlib.h>

int main() {

    int* out;
    out = (int*)malloc(sizeof(int) * 10);
    int cnt = 0;

    while(1){
        int i, j, k;
        int n;
        scanf("%d", &n);

        if(n == 0){
            break;
        } else {
            int *set;
            set = (int*)malloc((sizeof(int) * n));

            for(i = 0; i < n; i++){
                scanf("%d", set + i);
            }

            for(j = 1; j<n; j++){
            int key = set[j];
            i = j-1;
            while(i >= 0 && set[i] > key){
                set[i+1] = set[i];
                i--;
            }
            set[i+1] = key;
        }

        int sum = 0;
        for(k = 1; k < n-1; k++){
            sum += set[k];
        }
            
        free(set);

        if(cnt > sizeof(out)){
            out = (int*)realloc(out, sizeof(int) * cnt * 2);
        }
        out[cnt] = (int)(sum / (n-2));
        cnt++;
    }

}
    int index;
    for(index = 0; index < cnt; index++){
        printf("%d\n", out[index]);
    }
    
    free(out);

    return 0;

}
