Go: // ICPC 得点集計ソフトウェア
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; i++ {
			score_list = append(score_list, nextInt(sc))
		}

		// 最低点と最高点を取り除く (3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1:len(score_list)-1]

		// 平均点を求める
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

C++: #include <iostream>
#include <set>

using namespace std;

int main(){
     int N;
     while(cin>>N,N){
	  multiset<int> ten;
	  for(int i=0;i<N;i++){
	       int temp;
	       cin>>temp;
	       ten.insert(temp);
	  }
	  multiset<int>::iterator itr=ten.begin();
	  ten.erase(itr);
	  multiset<int>::reverse_iterator ritr=ten.rbegin();
	  ritr++;
	  ten.erase(ritr.base());
	  itr=ten.begin();
	  int sum=0;
	  while(itr!=ten.end()){
	       sum+=*itr;
	       itr++;
	  }
	  cout<<(int)sum/ten.size()<<endl;
     }
}

C++: #include <cstdio>

using namespace std;

int main(){
  int min,max,sum,n,score;

  while(1){
    scanf=0("%d",&n);
    if(!n) break;

    max=0;min=10000;sum=0;

    for(int i=0;i<n;i++){
        scanf("%d",&score);
        if(max<score) max=score;
        if(min>score) min=score;
        sum+=score;
    }

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

C++: #include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){

  int n;
  while(cin >> n,n){
    vector<int>v(n);
    for(int i=0;i<n;i++)cin >> v[i];
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=1;i<n-1;i++)ans += v[i];
    cout << ans/(n-2) << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int n,s[100],num,max=s[0],min=s[0];
  
  while(n != 0){
  cin>>n;    
    num=0;
    
  for(int i=0;i<n;i++){
    cin>>s[i];

    if(max<s[i])max=s[i];
    if(max>s[i])min=s[i];
       
    num += s[i];
  }
  num = (num-max-min)/n;
    cout<<num<<endl;

  }
  return 0;
}

C++: #include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    for(;;){
        int n;cin>>n;
        if(n==0)return 0;
        int a[n];
        rep(i,0,n)cin>>a[i];
        sort(a,a+n);
        int sum=0;
        rep(i,1,n-1)sum+=a[i];
        sum/=(n-2);
        cout<<sum<<endl;
    }
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	while(true){
		int score;
		int n;
		int maxs,mins;
		vector<int> s(n);
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>s[i];
		}
		maxs=*max_element(s.begin(),s.end());
		mins=*min_element(s.being(),s.end());
		for(int i=0;i<n;i++){
			score+=s[i];
		}
		cout<<(score-maxs-mins)/(n-2)<<endl;
	}
}

C++: #include <iostream>
using namespace std;

int main()
{
	int number;
	int score, sum, max, min;
	
	while(true)
	{
		cin >> number;
		if(!number) return 0;
		sum = 0, max = 0, min = 1000;
		for(int i = 0; i < number; ++i)
		{
			cin >> score;
			sum += score;
			if(score[i] > max) max = score;
			if(score[i] < min) min = score;
		}
		cout << (sum - max - min) / (number - 2) << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int n;
	while( cin >> n, n ){
		vector<int> v(n);
		for(int i=0; i<n; i++)
			cin >> v[i];
		sort( v.begin(), v.end() );
		int res = 0;
		for(int i=1; i<n-1; i++)
			res += v[i];
		cout << res/(n-2) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1e18 : 1e9;
const int MOD = 1000000007;
const long double EPS = 1e-8;


int main() {
	int n;
	while(cin >> n, n) {
		int macs = -1, mini = INF, sum = 0, s;
		rep (i, n) {
			cin >> s;
			macs = max(macs, s);
			mini = min(mini, s);
			sum += s;
		}
		cout << (sum - macs - mini) / (n - 2) << endl;
	}
	return 0;
}

C++: #include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

/** Problem1147 : ICPC Score Totalizer Software **/
int main()
{
	int N;
	vector<int> s;
	
	while (cin>>N, N) {
		int sum=0;
		s.clear();
		rep(i, N) {
			int n;
			cin >> n;
			s.push_back(n);
			sum+=n;
		}
		
		int m = *min_element(s.begin(), s.end());
		int M = *max_element(s.begin(), s.end());
		
		sum -= m; sum -= M;
		
		cout << sum/(N-2) << endl;
		
	}
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RFOR(i, a, b) for (int i=a;i>=b;--i)
#define ll long long
#define all(a) a.begin(),a.end()
#define ull unsigned long long
#define pb(x) push_back(x)
#define dbg(x) cout<<#x<<" : "<<(x)<<endl;
using namespace std;
const int INF = 1500000000;
const double PI = 3.14159265359;
const int mod = 1000000000 + 7;

int n, s[1000];

void solve() {
  int res = 0, mins = 1000, maxs = 0;
  rep(i, n) {
    res += s[i];
    maxs = max(maxs, s[i]);
    mins = min(mins, s[i]);
  }
  res -= maxs;
  res -= mins;
  printf("%d\n", res / (n-2));
}

int main() {
  while(true) {
    scanf("%d", &n);
    if (!n) break;
    rep(i, n) scanf("%d", &s[i]);
    solve();
  }
  return 0;
}