#include<stdio.h>


int main(){

  int n, s, sum, max, min;
  int i;

  while(scanf("%d", &n), n){\
    sum=0;
    max=0;
    min=1000;
    for(i=0;i<n;i++){
      scanf("%d", &s);
      if(max<s) max=s;
      if(min>s) min=s;
      sum+=s;
    }
    printf("%d\n", (sum-max-min)/(n-2));
  }


  return 0;
}