#include <stdio.h>

int main(void)
{
    int n;

    while (scanf("%d", &n), n){
        int point[128] = {0};
        int i, j;

        for (i = 0; i < n; i++) scanf("%d", point + i);
        for (i = 0; i < n - 1; i++){
            for (j = 0; j < n - i - 1; j++){
                if (point[j] > point[j + 1]){
                    int tmp = point[j];
                    point[j] = point[j + 1];
                    point[j + 1] = tmp;
                }
            }
        }
        point[0] = 0;
        for (i = 1; i < n - 1; i++){
            point[0] += point[i];
        }
        printf("%d\n", point[0] / (n - 2));
    }

    return 0;
}