main(){
	int n,s,S,m,M,i;
	for(;scanf("%d",&n),n;){
		S=0;
		M=0;
		m=1000;
		for(i=0;i<n;i++){
			scanf("%d",&s);
			S+=s;
			if(s>M)
				M=s;
			if(s<m)
				m=s;
		}
		printf("%d\n",(S-m-M)/(n-2));
	}
	exit(0);
}