#include <stdio.h>
int main(){
  int n,b,c,i,s;
  int min = 1000;
  int max = 0;
  int T[20];
  b = 0;
  T[b] = 0;
  while(1){
    scanf("%d",&n);
    if(n == 0)break;
    for(i=0;i<n;i++){
      scanf("%d",&s);
      if(s >= max) max = s;
      if(s <= min) min = s;
      T[b] += s;
    }
    T[b] = (T[b] - (min + max))/ (i - 2);
    b++;
    min = 1000;
    max = 0;
    i = 0;
    T[b] = 0;
  }
  for(c = 0; c<b; c++){
    printf("%d\n",T[c]);
  }
  return 0;
}