#include<stdio.h>
int main()
{
  int i=0,max,min,a[1000],sum=0,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum=sum+a[i];
    if(i==0){
      max=a[i];
      min=a[i];
    }
    if(max<a[i])
      max=a[i];
    if(min>a[i])
      min=a[i];
  }
  sum=sum-max-min;
  printf("%d\n",sum/(n-2));
  return 0;
}