#include<stdio.h>
void sort(int* a, int l, int r){
  int i, j, tmp;
  for(i = l; i < r; i++){
    for(j = r; j > i; j--){
      if (a[j - 1] > a[j]){
	tmp = a[j - 1];
	a[j - 1] = a[j];
	a[j] = tmp;
      }
    }
  }
}

int hogehoge(){
  int a = 0, b = 0, c = 0;
  return a + b + c;
}

int average(int a[], int l, int r){
  int i, sum = 0;
  for(i = l; i <= r; i++){
    sum += a[i];
  }

  return sum / (r - l + 1);
}

int main(void){
  int judge, score[100], i;
  while(1){

    scanf("%d", &judge);
    if(judge == 0){
      break;
    }
    for(i = 0; i < judge; i++){
      scanf("%d", &score[i]);
    }

    sort(score, 0, judge - 1);
    /* printf("\n"); */
    /* fflush(stdin); */
    hogehoge();
    printf("%d\n", average(score, 1, judge - 2));
  }

  return 0;
}