#include<stdio.h>
int main(){
    int i, max = 0, min = 0, sum = 0, n, tmp[1001] = {};
    for( sum = 0, min = 0, max = 0;scanf("%d", &n), n != 0;){
        for( i = 0; i < n; i++ ){
            scanf("%d", &tmp[i]);
            sum += tmp[i];
            if( i == 0 ){
                min = tmp[i];
                max = tmp[i];
            }else if( max < tmp[i] ){
                max = tmp[i];
            }else if( min > tmp[i] ){
                min = tmp[i];
            }
        }
        sum = sum - max - min;
        printf("%d\n", sum / (n - 2));
    }
    return 0;
}