#include <stdio.h>
int main(){
  int n,s,i,max,min,sum,ave;

  while(1){
    sum=0;
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&s);
      if(i==0){max=s;min=s;}
      if(s>=max)max=s;
      if(s<=min)min=s;
      sum+=s;
    }
    ave=(sum-max-min)/(n-2);
    printf("%d\n",ave);
  }

  return 0;
}