#include<stdio.h>
int main(void){
int n, s, sum, max, min, ave;

    while(1){
        scanf("%d", &n);
        if(!n) break;
 
        min = 1000; max = sum = 0;
        for(int i = 0; i < n; i++){
            scanf("%d", &s);
            
            if(max < s) max = s;
            if(min > s) min = s;
                
            sum += s;
        }
        ave = (sum - max - min)/(n - 2);
        printf("%d\n", ave);
    }
    return 0;
}

