#include <stdio.h>

int main(){
  int n,i,data[20],max,min,result;
  while(1){
    max = -1;
    min = 1001;
    result = 0;
    scanf("%d",&n);
    if(n==0)break;
    for( i = 0; i < n; i++){
      scanf("%d",&data[i]);
      result += data[i];
      if(max < data[i])
	max = data[i];
      if(min > data[i])
	min = data[i];
    }
    result = (result - min - max)/(n-2); 
    printf("%d\n",result);
  }
  return 0;
}