#include <stdio.h>

int main()
{
  int n;
  int i;
  int max, min, sum;
  int score[101];

  while (1) {
    scanf("%d", &n);

    if (n == 0)
      break;

    sum = 0;

    for (i = 0; i < n; i++) {
      scanf("%d", &score[i]);
      sum += score[i];

      if (i == 0) {
        max = score[i];
        min = score[i];
      }

      if (score[i] > max) max = score[i];
      if (score[i] < min) min = score[i];
    }

    printf("%d\n", sum - max - min / n - 2);
  }

  return 0;
}