/*
  AOJ 1147
  Title:
  @kankichi573
*/
#include <stdio.h>

#define Max(x,y) (((x)>(y))?(x):(y))
#define Min(x,y) (((x)<(y))?(x):(y))
main()
{
  int i,n,p,sum,min_,max_;


  while(scanf("%d",&n) && n)
    {
      sum=0;
      max_=0;min_=1000;
      for(i=0;i<n;i++)
	{
	  scanf("%d\n",&p);
	  sum += p;
	  min_ = Min(min_,p);
	  max_ = Max(max_,p);
	}
      //printf("sum=%d %d %d\n",sum,min_,max_);
      printf("%d\n",(sum-min_-max_)/(n-2));
    }
  return(0);
}