#include <stdio.h>

int main(void){
  int n,sum,ave,max,min;
  int num;
  int i;

  scanf("%d",&n);

  while(n != 0){
    sum = 0;
    ave = 0;
    min = 1001;
    max = -1;
    for(i=0;i<n;i++){
      scanf("%d",&num);
      sum += num;
      if(max <= num){
        max = num;
      }
      if(min >= num){
        min = num;
      }
    }

    sum = sum - max - min;

    ave = sum / n;

    printf("%d\n",ave);

    scanf("%d",&n);
  }

  return 0;
}