#include <stdio.h>

int main() {
    int max, min ,n, s[128], i;
    int x;
    
    do {
        scanf("%d", &n);
        if(!n)
            break;
        
        max = 0;
        min = 1000;
        temp = 0;
        
        for(i = 0; i < n; i++) {
            scanf("%d", &s[i]);
            if(s[i] > max)
                max = s[i];
            if(min > s[i])
                min = s[i];
            
            x += s[i];
        }
        
        printf("%d\n", (x - max - min) / (n - 2));
    } while(1);
    
    return 0;
}