#include <stdio.h>

int main(void){
  int i,j,work,n,s[100],sum=0;
  
  while(1){
    scanf("%d",&n);
    if(n == 0) break;
    for(i=0;i<n;i++){
      scanf("%d",&s[i]);
    }
    for(i=0;i<n;i++){
      for(j=0;j<n-1;j++){
	if(s[i]>s[j]){
	  work = s[i];
	  s[i] = s[j];
	  s[j] = work;
	}
      }
    }
    
    
    
    for(i=1;i<n-1;i++){
      sum += s[i];
      s[i] -= s[i];
    }
    printf("%d\n",sum/(n-2));
    sum -= sum;
    
  }
  
  return 0;
}