import java.util.Scanner;
public class p2309 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int n=sc.nextInt();
if(n==0){
break;
}
int sum=0;
//用来标记最高分和最低分
int max=0,min=10000;
int []a=new int[n];
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
sum=sum+a[i];
if(a[i]>max){
max=a[i];
}
if(a[i]<min){
min=a[i];
}
}
sum=sum-max-min;
System.out.println(sum/(n-2));
}
}
}