#include <stdio.h>

int main() {
    int n, i;
    int max, min, sum;
    int score;

    while (1) {
        scanf("%d", &n);

        if (n == 0) { break; }

        sum = 0;

        for (i = 0; i < n; i++) {
            scanf("%d", &score);
            sum += score;
        
            if (i == 0) {
                max = score;
                min = score;
            }

            if (score > max) { max = score; }
            if (score < min) { min = score; }
        }

        printf("%d\n", (sum - max - min) / (n - 2));
    }

    return 0;
}
