#include<stdio.h>
int main(){
  int i;
  int h=0;
  int n=0;
  int s[20];
  int num=0;
  int sum=0;
  int average=0;
  int nummax=0;
  int nummin=1001;
  int inputcount = 0;
  while(1){
    scanf("%d",&n);//?????°
    if(n==0) break;
    for(i=0;i<n;i++){	
      scanf("%d",&num);//?????°
      if(num<nummin)nummin=num;
      if(nummax<num)nummax=num;
      sum+=num; 
    }
    sum -= nummax+nummin;
    h=n-2;
    average=sum/h;
    s[inputcount] = average;
    inputcount++;
  }
  for(i = 0;i < inputcount;i++)
      printf("%d\n",s[i]);
  return 0;
}