#include <stdio.h>

int main(void){

  int n,i;

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

    int point[100]={0};

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

    int max=0,min=1000,maxnum,minnum;

    for(i=0;i<n;i++){
      if(max<=point[i]){
        maxnum=i;
        max=point[i];
      }
      if(min>=point[i]){
        minnum=i;
        min=point[i];
      }
    }

    point[minnum]=0;
    point[maxnum]=0;
    
    int sum=0;
    for(i=0;i<n;i++)
      sum+=point[i];

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

  return 0;
}