#include <stdio.h>
#define MAX 101

int main(void)
{
	int n,i,t;
	int s[MAX],maxs=0,mins=1001,total=0;
	
	while(t!=1)
	{
		scanf("%d",&n);
		if(n==0)
		{
			t = 1;
		}
		else
		{
			for(i=0;i<=n-1;i++)
			{
				scanf("%d",&s[i]);
			}
			for(i=0;i<=n-1;i++)
			{
				if(s[i]>=maxs)
				{
					maxs = s[i];
				}
			}
			for(i=0;i<=n-1;i++)
			{
				if(s[i]<=mins)
				{
					mins = s[i];
				}
			}
			for(i=0;i<=n-1;i++)
			{
				total += s[i];
			}
			total = (total - maxs - mins);
			n = n-2;
			//printf("%d\n %d\n %d\n",maxs,mins,total);
			printf("%d\n",total/n);
			
			maxs = 0;
			mins = 1001;
			total = 0;
		}
		
	}
	return 0;
}