#include<stdio.h>
int main(){
  int s,min,max,n,p,i;
  while(scanf("%d",&n),n){
    min=2000;
    for(i=max=s=0;i<n;i++){
      scanf("%d",&p);
      s+=p;
      if(max<p)max=p;
      if(min>p)min=p;
    }
    s-=min+max;
    printf("%d\n",s/(n-2));
  }
  return 0;
}