#include<stdio.h>

int main(void)
{
  int n;
  int s[100];
  int i;
  int max = 0;
  int min = 0;
  int sum = 0;
  int avg;

  
  while(1){
    scanf("%d",&n);
    if(n == 0)
      break;
    
    for(i = 0;i < n;i++){
      scanf("%d",&s[i]);
      if(i != 0 && s[i] > s[max])
	max = i;
      if(i != 0 && s[i] < s[min])
	min = i;
    }

    for(i = 0;i < n;i++)
      sum += s[i];
    
    sum = sum - s[max] - s[min];
    
    avg = sum / (n-2);

    printf("%d\n",avg);
    
    max = 0;
    min = 0;
    sum = 0;
  }

  return 0;
}
  