#include <stdio.h>
int main(void){
    int size[20] = {};
    int number[100] = {};
    int max, min, total;
    
    for (int i = 0; scanf ("%d", &size[i]), size[i] != 0; i++){
        max = 0, min = 1000, total = 0;
        for (int j = 0; j < size[i]; j++){
            scanf ("%d", &number[j]);
            total += number[j];
            if (max < number[j]) max = number[j];
            if (min > number[j]) min = number[j];
        }
        total -= max + min;
        total /= size[i] - 2;
        printf ("%d\n", total);
    }
}