i,x,n,m,a;int main(){int j[104];for(;scanf("%d",&a)&&a;x=0,n=0,m=0){for(i=0;i<101;i++)j[i]=0;j[i++]=-1;j[i]=1001;for(i=0;a-i&&scanf("%d",&j[i]);i++){if(j[101]<j[i])j[101]=j[i];if(j[102]>j[i])j[102]=j[i];m+=j[i];}printf("%d\n",m=(m-(j[101]+j[102]))/(a-2));}exit(0);}