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

package main

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

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

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

int main(){
	int n;
	while (std::cin >> n && n){
		std::vector<int> score;
		for (int i = 0; i < n; ++i){
			int s;
			std::cin >> s;
			score.push_back(s);
		}
		std::sort(score.begin(), score.end());
		score.pop_back();
		score.erase(score.begin());
		int ans = 0;
		int cnt = 0;
		for (auto it = score.begin(); it != score.end(); ++it){
			ans += *it;
			cnt++;
		}
		std::cout << ans/cnt << std::endl;
	}
	return 0;
}

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;
}