#include <stdio.h>
#include <stdlib.h>
#define N_MAX 100

int cmpint(const void *a, const void *b)
{
  return * (int*) a - * (int*) b;
}

int main()
{
  static int score[N_MAX];
  int n, i, sum;
  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;
    for (i = 0; i < n; i++) {
      scanf("%d", &score[i]);
    }
    qsort(score, n, sizeof(int), cmpint);
    sum = 0;
    for (i = 1; i <= n - 2; i++) {
      sum += score[i];
    }
    printf("%d\n", sum / (n - 2));
  }
  return 0;
}