#include<stdio.h>
#include<stdlib.h>

int qtmp(const void *a,const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int i,n;

    int ascore[20] = {};
    int count=0;

    while(1){
    scanf("%d",&n);
    if(n == 0) break;

    int score[n];

    for(i=0;i<n;i++){
        scanf("%d",&score[i]);
    }

    for(i=0;i<n;i++){
        qsort(score,n,sizeof(int),qtmp);
    }

    double dave=0;
    int iave=0;

    for(i=1;i<n-1;i++){
        dave += score[i];
    }

    iave = (int)((dave / (n-2)));

    ascore[count] = iave;
    count++;

    }

    for(i=0;i<20;i++){
        if(ascore[i] == 0) break;
        printf("%d\n",ascore[i]);
    }

    return 0;
}
