#include <stdio.h>
int main()
{
  int n, s[20], i, max, min, total, average;

  while(1){
    scanf("%d", &n);
    if(n == 0)
      break;
    for(i=0;i<n;i++){
      scanf("%d", &s[i]);
    }
    max = min = s[0];
    for(i=1;i<n;i++){
      if(max < s[i])
	max = s[i];
      if(min > s[i])
	min = s[i];
    }
    total = 0;
    for(i=0;i<n;i++){
      total += s[i];
    }
    
    total = total - max - min;
    average = total / (n-2);
    printf("%d\n", average);
  }
  return 0;
}