#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int judgeNum, sum, inputCache, max, min, i;

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