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