#include <stdio.h>
#define MAX 101


int main(void)
{
  int i, j, n, t=0, hikaku=0, delmax, delmin, sum=0;
  int heikin;
  int point[MAX];


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

      else
	{
	  for(i=0;i<n;i++)
	    {
	      scanf("%d",&point[i]);
	    }
	  
	  /*CHECK!!!
	    for(i=0;i<=n-1;i++)
	    {
	    printf("point[%d] %d\n",i,point[i]);
	    }
	  */
	  
	  for(i=0;i<=n-1;i++)
	    {
	      if(hikaku<=point[i])
		{
		  hikaku = point[i];
		  delmax = i;
		}
	    }
	  hikaku = 1001;
	  for(i=0;i<=n-1;i++)
	    {
	      if(hikaku>=point[i])
		{
		  hikaku = point[i];
		  delmin = i;
		}
	    }
	  
	  for(i=0;i<=n-1;i++)
	    {
	      sum = sum + point[i];
	    }
	  
	  sum = sum - (point[delmin] + point[delmax]);
	  //printf("%d\n",sum);

	  if(n-3==0)
	    {
	      heikin = sum;
	    }
	  else
	    {
	      heikin = sum / (n-2);
	    }

	  printf("%d\n",heikin);
	  hikaku = 0;
	  delmax = 0;
	  delmin = 0;
	  sum = 0;
	}
    }
  return 0;
}