#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,x=0,max=-1,min=1001,score = 0,i;
    
    while (1) {
        
        scanf("%d",&n);
        
        if (n == 0) {
            break;
        }
        
        for (i = 0; i < n; i++) {
            
            scanf("%d",&x);
            score += x;
            if (x > max) {
                max = x;
            }
            if (x < min) {
                min = x;
            }
            
        }
        printf("%d\n",(score-min-max)/(n-2));
        score = 0;
        x = 0;
        max = -1;
        min = 1001;
    }
    return 0;
}