#include<bits/stdc++.h>
using namespace std;
int main(){//C++10级 最终得分
int n,high=0,low=100,scroe;
long long sum=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>scroe;
sum+=scroe;
high=max(high,scroe);
low=min(low,scroe);
}
cout<<(sum-high-low)/(n-2);
return 0;
}