#include <stdio.h>

#define MAX_N 100

int main(){
  int n,max,min,i,arr[MAX_N],sum;
  while(1){
    max = sum = 0; min = 1000;
    scanf("%d",&n);
    if(n == 0){ break; }
    for(i = 0 ; i < n ; i++){
      scanf("%d",&arr[i]);
      if(max < arr[i]){ max = arr[i]; }
      if(min > arr[i]){ min = arr[i]; }
      sum += arr[i];
    }
    printf("%d\n",(sum-max-min)/(n-2));
  }
  return 0;
}