#include <stdio.h>

int main(void)
{
  int n = 0, x = 0, i;
  int min = 1000, max = 0, sum = 0;
  
  while(1){
    scanf("%d",&n);
    if(n == 0){
      break;
    }
    sum = 0;
    max = 0;
    min = 1000;
    for(i = 0 ; i < n ; i++){
      scanf("%d",&x); 
      if(x < min){
	min = x;
      }
      if(x > max){
	max = x;
      }
      sum += x;
    }

  sum -= min;
  sum -= max;
  
  printf("%d\n",sum/(n - 2));
  }

  
  return 0;
}