#include <stdio.h>

int main() {
  int n, s;
  while (~scanf("%d", &n) && n>0) {
    int i, sum = 0, largest = 0, smallest = 1000, avg;

    for (i=0; i<n; i++) {
      scanf("%d", &s);
      sum += s;
      if(largest < s) largest = s;
      if(smallest > s) smallest = s;
    }

    sum -= (largest + smallest);
    avg = sum / (n-2);
    printf("%d\n", avg);

  }
  
  return 0;
}