#include <stdio.h>
#define MAX 100
int main(){
  int i,n,s[MAX],max=0,min=0,point;
  float p,sum;
  scanf("%d",&n);
  while(n){
    sum=0;
    for(i=0;i<n;i++){
      scanf("%d",&s[i]);
    }
    max=s[0];
    min=s[0];
    for(i=0;i<n;i++){
      if(max<s[i]){
	max=s[i];
      }
      if(min>s[i]){
	min=s[i];
      }
    }
      for(i=0;i<n;i++){
	sum+=s[i];
      }
      sum-=max;
      sum-=min;
      n-=2;
      p=sum/n;
      point=(int)p;
      printf("%d\n",point);
      scanf("%d",&n);
  }


  return 0;
}