#include<stdio.h>
int main(){
int i,j,a[200],n,min,max,k,x;
while(scanf("%d",&n)!=EOF){
x=0;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
max=a[0];
min=a[0];
for(j=1;j<n;j++){
if(a[j]>=max)
max=a[j];
if(a[j]<=min)
min=a[j];
}
for(k=0;k<n;k++)
x+=a[k]
printf("%d\n",(x-max-min)/(n-2));
}
return 0;
}