#include<stdio.h>
int main()
{
  int n, i, maxs, mins, score, sum, ave;
  while(scanf("%d", &n) != EOF)
    {
      if(n == 0) break;
      scanf("%d", &score);
      maxs = mins = sum = score;
      for(i = 1; i < n; i ++){
	scanf("%d", &score);
	sum += score;
	if(score > maxs) maxs = score;
	if(score < mins) mins = score;
      }
      sum -= maxs + mins;
      ave = sum / (n - 2);
      printf("%d\n", ave);
    }
}