#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	while(scanf("%lld",&n),n){
		ll M=0;
		ll m=1000;
		ll s=0;
		rep(i,0,n){
			ll t;
			scanf("%lld",&t);
			M=max(M,t);
			m=min(m,t);
			s+=t;
		}
		printf("%lld\n",(s-m-M)/(n-2));
	}
}
