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