#include<stdio.h>

int main() {

  int num, i, score[100], max, min, sum, ave;

  while(1) {
    max = 0;
    min = 1000;
    sum = 0;
    scanf("%d", &num);

    if(num == 0) break;

    for(i = 0; i < num; i++) {
      scanf("%d", &score[i]);

      sum += score[i];
      if(score[i] > max) max = score[i];
      if(score[i] < min) min = score[i];
    }

    sum = sum - min - max;
    ave = sum / (num - 2);

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

    for(i = 0; i < num; i++) {
      score[i] = 0;
    }
    
  }
}

