
int main(void){
  int i,n,s,total,max,min;

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

    min=1000;
    total=max=0;
    for(i=0;i<n;i++){
      scanf("%d",&s);
      total+=s;
      if(max<s){max=s;}
      if(min>s){min=s;}
    }
    printf("%d\n",(total-max-min)/(n-2));
  }

  return 0;
}