
#include <stdio.h>

int main(){
    int i,a[i],n,l=0,s=1000,t;
    double x;
    do{
        
    scanf("%d",&n);
        if (n==0) break;
        for (i=0;i<n;i++) {
            scanf("%d",&a[i]);
            if (l<a[i]) {l=a[i];}
            if (s>a[i]) {s=a[i];}
        
       
    
        for (i=0,t=0;i<n;i++) {
            t=t+a[i];
        }
        t=t-l-s;
        x=t/(n-2);
        printf("%d",(int)x);
    
       
        
    }
    }
    return 0;
}