#include<stdio.h>
int main(void) {
	int n, s[100] = {0}, max, min,sum=0,count=0;
	scanf("%d", &n);
	for (int i = n; i > 0; i--) {
		scanf("%d", &s[i]);
		if (i == n) {
			max = s[i];
			min = s[i];
		}
		if (max < s[i]) max = s[i];
		if (min > s[i]) min = s[i];
		count++;
		if (s[i] == 0) break;
		sum += s[i];
	}
	sum = sum - (max + min);
	printf("%d", sum/(count-2));
	return 0;
}