#include<stdio.h>

int main(){
  int n,a[n],sum,min,max;
  double ave;
  for(i=0,i<21,i++){
    scanf("%d",&n);
    if(n==0)
      break;
    elif{
      sum = 0;
      min = 1000;
      max = 0;
      for(i=0;i<n;i++){
        scanf("%d",&f[i]);
        sum += f[i];
      }
      for(i=0;i<n;i++){
        if(min>a[i])min=a[i];
        if(max<a[i])max=a[i];
      }
      ave = (sum - min -max)/(n-2);
      printf("%d",ave);
    }
  }
  return o;
}