#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a, const void *b)
{
  return *(int*)a- *(int*)b;
}

int main(void)
{
  int count=0, check=0, i, sum=0, avg=0;
  int score[100]={0};
  while(1)
    {
      scanf("%d", &count);
      if(count==0)
	{
	  break;
	}

      for(i=0; i<count; i++)
	{
	  scanf("%d", &check);
	  score[i]=check;
	}

      qsort(score, i, sizeof(int), compare_int);
      for(i=1; i<count-1; i++)
	{
	  sum+=score[i];
	}
      avg=sum/(count-2);

      printf("%d\n", avg);
    }
}