#include <stdio.h>

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

  scanf("%d",&n);

  while(n > 0){
    sum = 0;
    max=0;
    min=1001;
    for (i=0;i<n;i++){
      scanf("%d",&s);
      if (s>max){
	sum += max;
	max=s;
      }else if(s<min){
	if(min!=1001) sum +=min;
	min=s;
      }else{
	sum +=s;
      }
    }
    printf("%d\n",sum/(n-2));
    scanf("%d",&n);
  }
  return 0;
}