#include <stdio.h>

int main(void)
{
  int n; // # of judges; 3 <= n && n <= 100
  int input, input2, score, max_score, min_score;
  int i;

  while (1) {
    scanf("%d", &n);
    if (n == 0) break;

    // scanf the first two value for temporaly max(min) value
    scanf("%d", &input);
    scanf("%d", &input2);
    if (input < input2) {
      min_score = input;
      max_score = input2;
    } else {
      min_score = input2;
      max_score = input;
    }

    score = 0;

    // score = sum - (min + max)
    for (i=0; i<n-2; i++) {
      scanf("%d", &input);
      if (input > max_score) {
        score += max_score;
        max_score = input;
      } else if (input < min_score) {
        score += min_score;
        min_score = input;
      } else {
        score += input;
      }
    }
    
    printf("%d\n", score / (n-2));
  }

  return 0;
}