#include <stdio.h>

int main(void){

	while(1){
		int c;
		scanf("%d",&c);
		if(!c) break;
		int max = 0, min = 1000;
		for(int i=0; i<c; i++){
			int n;
			scanf("%d",&n);
			max = (max>n) ? max:n;
			min = (min<n) ? min:n;
			sum += n;
		}
		n -= (max + min);
		printf("%d\n",n/(c-2);
	}

	return 0;
}