#include <stdio.h>

int main(){

  int a, n, i, ave, total=0, max=0, min=1000;


    scanf ("%d", &n);
  
    for (i = 1; i <= n; i++){
      scanf ("%d",&a);
      total = total + a;
      if (a >= max){
	max = a;
      }
      if (a <= min){
	min = a;
      }
    }
    ave = (total - max - min) / ( n - 2);
    printf ("%d\n", ave);
  
  return 0; 
}