#include<stdio.h>
#include<string.h>
 
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
 
int main(){
    int i,n,a[100],t[100],u[100],ch,s,total;
        while(1){
        scanf("%d",&n);
        if(n==0) break;
                for(total=0,i=0;i<n;i++){
                        scanf("%d",&a[i]);
                }
                        memcpy(t,a,sizeof(a[0]) * 100);
                        memcpy(u,a,sizeof(a[0]) * 100);
                for(i=0;i<n-1;i++){
                        t[i+1] = max(t[i],t[i+1]);
                        u[i+1] = min(u[i],u[i+1]);
                }
                for(i=0;i<n;i++) total+=a[i];
                printf("%d\n",(total-t[n-1]-u[n-1])/(n-2));
        }
        return 0;               
}