#include <stdio.h>

#define MAX_N 100

int main(){
  int n,max,min,i,arr[MAX_N],sum;
  int use_max,use_min;
  while(1){
    use_max = use_min = 0;
    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]; }
    }
    for(i = 0 ; i < n ; i++){
      if(max == arr[i]){
        if(use_max == 0){
          use_max = 1;
          continue;
        }
      }
      if(min == arr[i]){
        if(use_min == 0){
          use_min = 1;
          continue;
        }
      }
      sum += arr[i];
    }
    printf("%d\n",sum/(n-2));
  }
  return 0;
}