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