#include<stdio.h>
 
int main()
{
  int i,j,a[1000],b,c1,c2,n,sum,c4=0,c3=0;
  while(1){
    sum=0;
    j=0;c4=0;c3=0;
  scanf("%d",&n);
  if(n==0)break;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(i==0){c1=a[i];c2=a[i];}
    else{
      if(c1<a[i]){c1=a[i];c3=i;}
      if(c2>a[i]){c2=a[i];c4=i;}
    }
  }
  for(i=0;i<n;i++){
    if(c3==i||c4==i){b++;}
    else{
    sum+=a[i];
    j++;
    }
  }
  printf("%d\n",sum/j);
}
  return 0;
}
 