/*
AizuOnline A1147
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n,point[100];
//
int comp(void * x,void * y)
{
  return(*(int *)x- *(int *)y);
}
main()
{
  int i,m,sum;
  
  while(EOF!=scanf("%d ",&n) && n)
    {
      for(i=0;i<n;i++)
	scanf("%d",&(point[i]));

      qsort(point,n,sizeof(int),comp);

      sum=0;m=0;
      for(i=1;i<n-1;i++)
	  {
	    m++;
	    sum += point[i];
	  }
      printf("%d\n",sum/m);
    }
return(0);
}