#include<stdio.h>
int main()
{
  int n, score, total, max, min, i;

  while(1){
    total = 0;
    max = -1;
    min = 10000;
    
    scanf("%d", &n);
    if(n == 0) break;

    for(i = 0; i < n; i++){
      scanf("%d", &score);
      total += score;

      if(max < score){
	max = score;
      }
      
      if(score < min){
	min = score;
      }
      
    }

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

  }
  
  return 0;
  
}