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<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        int sum = 0,a,maxi = INF,mini = 0;
        rep(i,0,N){
            cin >> a;
            sum += a;
            maxi = max(maxi, a);
            mini = min(mini, a);
        }
        sum -= (maxi + mini);
        cout << sum / N << endl;
        cin >> N;
    }
}

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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> s(n);
        for (auto &si: s) cin >> si;
        sort(s.begin(), s.end());
        int sum = accumulate(s.begin(), s.end(), 0) - s.front() - s.back();
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

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

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      vector<int> p;
      for(;n--;)
	{
	  int t;
	  cin>>t;
	  p.push_back(t);
	}
      sort(p.begin(),p.end());
      int sum=0;
      for(int i=1;i<p.size()-1;i++)
	sum+=p[i];
      cout<<sum/(p.size()-2)<<endl;
    }

}

C++: #include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>

#define BIT(a) (1 << (a))

using namespace std;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

vector<int> v[30];
int ans[30];
int main(void){
	int N;
	int cnt = 0;
	while (1){
		cin >> N;
		if (N == 0) break;
		for (int i = 0; i < N; i++){
			int x;
			cin >> x;
			v[cnt].push_back(x);
		}
		cnt++;
	}
	for (int i = 0; i < cnt; i++){
		sort(v[i].begin(), v[i].end());
		for (int j = 0; j < v[i].size(); j++){
			if (j == 0 || j == v[i].size()-1) continue;
			ans[i] += v[i][j];
		}
		ans[i] /= v[i].size() - 2;
	}

	for (int i = 0; i < cnt; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
using llong = long long;

llong n;
llong sum;
llong m;

int main() {

    while (scanf("%lld", &n), n != 0) {
        llong minv = 1ll << 60ll;
        llong maxv = -1;
        sum = 0;
        
        for (int i = 0; i < n; i++) {
            cin >> m;

            sum += m;

            minv = min(minv, m);
            maxv = max(maxv, m);
        }

        cout << (sum - maxv - minv) / (n - 2) << endl;
    };

    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s[120],count;;
	while(true){
		cin>>n;
		if(n==0)
			break;
		count=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			count+=s[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(s[j]<s[j-1]){
					int tmp=s[j];
					s[j]=s[j-1];
					s[j-1]=tmp;
				}
			}
		}
		count-=s[0];
		count-=s[n-1];
		cout<<count/(n-2)<<endl;
	}
    return 0;
}

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

int main()
{
	int n,s[100],max,min,nmax,nmin,ret;
	while (cin >> n, n) {
		for(int i = 0;i < n;i++) {
			cin >> s[i];
		}
		min = 1000;
		max = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] > max){
				max = s[i];
				nmax = i;
			}
			if (s[i] < min) {
				min = s[i];
				nmin = i;
			}
		}
		s[nmax] = s[nmin] = 0;
		ret = 0;
		for (int i = 0; i < n; i++) {
			ret += s[i];
		}
		cout << ret / (n - 2) << endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>

#pragma warning(disable:4996)

using namespace std;

int main() {
  while (true) {
    int size;
    cin >> size;
    if (size == 0) {
      break;
    }
    vector<int> v(size);
    for (auto&& vv : v) {
      cin >> vv;
    }
    sort(v.begin(), v.end());
    cout << accumulate(v.begin() + 1, v.end() - 1, 0) / (v.size() - 2) << endl;
  }
  return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(ll n){
    vector<ll> score(n); for(auto& in:score) cin >> in;
    sort(score.begin(),score.end());
    return accumulate(score.begin()+1,score.end()-1,0LL)/(n-2);
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n;
    while(cin >> n,n){
        cout << solve(n) << endl;
    }
    return 0;
}