#include<stdio.h>
int main(){
  int n,s,min,max,p,i;
  while(scanf("%d",&n),n){
    min=1100;
    max=0;
    for(i=s=0;i<n;i++){
      scanf("%d",&p);
      s+=p;
      if(max<p)max=p;
      if(min>p)min=p;
    }
    printf("%d\n",(s-max-min)/(n-2));
  }
  return 0;
}
  