#include <stdio.h>

int main(){
  int judge, in, sum, max, min;

  while(1){
    scanf("%d", &judge);
    if(judge==0) break;

    sum=0; max=0; min=1000;
    
    int i;
    for(i=0;i<judge;i++){
      scanf("%d", &in);
      sum += in;
      if(in >= max) max = in;
      if(in <= min) min = in;
    }
    
    printf("%d\n", (sum - max - min)/(judge-2));
  }
  
  return 0;
}