#include <stdio.h>
int main(void){
  int k,n,s[100],i,min,max,sum;
  for(k = 0; k < 20; k++){
  scanf("%d", &n);
  if(n == 0) break;
  for(i = 0; i < n; i++){
      scanf("%d", &s[i]);
  }
  min = s[0];
  max = s[0];
  sum = 0;
  for(i = 0; i < n; i++){
      if(min > s[i]){
          min = s[i];
      }
      if(max < s[i]){
          max = s[i];
      }
      sum += s[i];
  }
  printf("%d\n", (sum - min - max)/(n -2));
  }
  return 0; 
}

