#include <stdio.h>

int main(void) {
  int i, n, tmp, sum;

  while (1) {
    int data[100];
    int max=0, min=0;
    int sum = 0;

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

    for(i=0; i < n; i++) {
      scanf("%d", &data[i]);
      if (i==0) {
        min = data[i];
        max = 0;
      }
      if (data[i] > max) {
        max = data[i];
      }
      if (data[i] < min) {
        min = data[i];
      }
    }

    for(i=0; i < n; i++) {
      sum += data[i];
    }
    sum -= min+max;
    n -= 2;
    printf("%d\n", (int)sum/n);
  }

  return 0;
}