#include<stdio.h>

int main(void){
    int p[1000000]={0};
    int avarage[100000]={0};
    int n=0,count=0;
    int s=0,max=0,min=0;
    while(1){
        max=0;
        min=0;
        scanf("%d",&n);
        if(n==0){
            break;
        }
        for(int i=0;i<n;i++){
            scanf("%d",&s);
            if(i==0){
                max=s;
                min=s;
            }
            if(s>max){
                max=s;
            }
            if(s<min){
                min=s;
            }
            p[count]+=s;
        }
        p[count]-=max+min;
        avarage[count]=p[count]/(n-2);
        count++;
    }
    for(int i=0;i<count;i++){
        printf("%d\n",avarage[i]);
    }
    return 0;
}
