#include <stdio.h>
#include <limits.h>

#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int min = INT_MAX
      , max = INT_MIN
      , sum = 0;
    int n;

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

    for ( i = 0; i < n; ++i )
    {
      int d;

      scanf ( "%d", &d );
      min   = MIN( min, d );
      max   = MAX( max, d );
      sum  += d;
    }

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

  return ( 0 );
}