#include <stdio.h>
#include <math.h>

int main()
{
  int i, n, buff, max, min;
  double result;
  
  scanf("%d", &n);
  
  while (1) {
    if (n == 0)
      break;
    
    result = 0;
    max = 0;
    min = 1000;
    
    for (i = 1; i <= n; i++) {
      scanf("%d", &buff);
      result += buff;
      
      if (buff > max)
	max = buff;
      if (buff < min)
	min = buff;
    }
    
    result = (result - max - min) / (n - 2);
    printf("%d\n", (int)floor(result));
    
    scanf("%d", &n);
  }

  return 0;
}