#include<stdio.h>

int main(void){
  int ans[1024];
  int n;
  int k,i,j,tmp;
  for(k=0;k>=0;k++){
    int total=0;
    scanf("%d",&n);
    if(n==0)break;
    int point[n];
    for(i=0;i<n;i++){
      scanf("%d",&point[i]);
    }
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
	if(point[i]>point[j]){
	  tmp = point[i];
	  point[i] = point[j];
	  point[j] = tmp;
	}
      }
    }
    for(i=1;i<n-1;i++){
      total += point[i];
    }
    ans[k] = total/(n-2);
  }  
  for(i=0;i!=k;i++){
    printf("%d\n",ans[i]);
  }
  return 0;
}