#include <stdio.h>

int main(void){

  int i;
  int judge_number;
  int result_point;

  while(1){
    
    int points[101]={0};
    int max_point=0;
    int min_point=0;
    int max_index=0;
    int min_index=0;
    int sum=0;

    scanf("%d",&judge_number);
    
    if(judge_number==0){
      break;
    }

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

      if(i==0){
	max_point=points[i];
	min_point=points[i];
      }

      else if(max_point<points[i]){
	max_point=points[i];
	max_index=i;
      }

      else if(min_point>points[i]){
	min_point=points[i];
	min_index=i;
      }

    }

    for(i=0;i<judge_number;i++){
      if(i!=max_index && i!=min_index){
	sum+=points[i];
      }
    }

    result_point=sum/(judge_number-2);

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

  }

  return 0;

}
    