#include<stdio.h>

int main()
{
  short n,i;
  char k;
  int score[100];
  int max,min,sum;

  while(1){
    k = 0;
    sum = 0;

    scanf("%hd",&n);
    if(n == 0){
      break;
    }

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

      if(k == 0){
        min = score[i];
        max = score[i];
        k = 1;
      }
      else{
        if(score[i] > max){
          max = score[i];
        }
        else if(score[i] < min){
          min = score[i];
        }
      }

      sum = sum + score[i];
    }

    sum = sum - (max + min);
    sum = sum / (n-2);

    printf("%d\n",sum);
  }

  return 0;
}