#include<stdio.h>

int main(void)
{
  int i,j,tmp;
  int n,s[100];
  int sum;

  while(1){
    scanf("%d ",&n);
    if(n==0)break;

    for(i=0;i<n;i++){
      scanf("%d ",&s[i]);
    }

    for(i=n-1;i>0;i--){
      for(j=0;j<i;j++){
	if(s[j]<s[j+1]){
	  tmp = s[j];
	  s[j] = s[j+1];
	  s[j+1] = tmp;
	}
      }
    }
    sum = 0;
    for(i=1;i<n-1;i++){
      sum += s[i];
    }

    printf("%d\n",sum/(n-2));

  }

  return 0;
}