#include <stdio.h>

int min(int a, int b)
{
    if (a > b){
        return (b);
    }
    return (a);
}

int max(int a, int b)
{
    if (a > b){
        return (a);
    }
    return (b);
}

int main(void)
{
    int n, s;
    int i;
    int min_, max_, t;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        s = 0;
        for (i = 0; i < n; i++){
            scanf("%d", &t);
            if (i == 0){
                min_ = max_ = t;
            }
            min_ = min(min_, t);
            max_ = max(max_, t);
            s += t;
        }
        
        printf("%d\n", (s - min_ - max_) / (n - 2));
    }
    
    return (0);
}