#include <stdio.h>

int main(void){

  char scan[8];
  int loop1, loop2, loop3, result, n, n_judge[100], max, min;

  while(1){
    for(loop1 = 0; loop1 < 8; loop1++){
      scan[loop1] = '\0';
    }
    for(loop1 = 0; loop1 < 100; loop1++){
      n_judge[loop1] = '\0';
    }
    result = 0;

    fgets(scan, 8, stdin);
    n = atoi(scan);

    if(n == 0) break;

    for(loop1 = 0; loop1 < n; loop1++){
      fgets(scan, 8, stdin);
      n_judge[loop1] = atoi(scan);
      for(loop2 = 0; loop2 < 8; loop2++){
	scan[loop2] = '\0';
      }
    }
 
    max = n_judge[0];
    min = n_judge[0];

    for(loop1 = 0; loop1 < n; loop1++){
      result += n_judge[loop1];
      if(n_judge[loop1] > max) {max = n_judge[loop1];
	printf("max %d\n", max);}
      if(n_judge[loop1] < min) {min = n_judge[loop1];
	printf("min %d\n", min);}
    }

    result -= max;
    result -= min;

    n = n - 2;
    result = result / n;

    printf("%d\n", result);

  }

}