#include <stdio.h>

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

