#include <stdio.h>
int main(void){
  int data,judge,point;
  int i,j,sum,max,min;
  for(i=0;1;i++){
    scanf("%d",&judge);
    if(judge==0) break;
    sum=0;
    max=0;
    min=1000;
    for(j=0;j<judge;j++){
      scanf("%d",&point);
      sum+=point;
      max = (max<point) ? point:max;
      min = (min>point) ? point:min;
    }
    data=sum-min-max;
    data/=(judge-2);
    printf("%d\n",data);
  }
  return 0;
}