#include <stdio.h>

int main() {
    int n, i, score;;
    int max = -1, min = 1001, sum;

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

        if (n == 0) { break; }

        sum = 0;

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

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

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

    return 0;
}
