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 <queue>
using namespace std;

int main()
{
    int n;
    while(cin>>n){
        
        if(n==0){
            break;
        }
        priority_queue<int> maxpq;
        int a, b=0;
        
        for(int i=0; i<n; i++){
            cin >> a;
            maxpq.push(a);
        }
        
        maxpq.pop();
        
        for(int i=0; i<n-2; i++){
            b +=maxpq.top();
            maxpq.pop();
        }
        
        cout << b/(n-2) << endl;
    }
    
    return 0;
}

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

int main(){
    int n;

    while(cin >> n, n != 0){
        vector<int> s;
        for(int i=1; i<=n; i++){
            int tmp;
            cin >> tmp;
            s.push_back(tmp);
        }
        sort(s.begin(), s.end());


        s.at(0) = 0;
        s.at(s.size()-1) = 0;

        vector<int>::iterator it = s.begin();
        int sum = 0;
        while(it != s.end()){
            sum += *it;
            it++;
        }
        cout << sum / (s.size()-2) << endl;
    }
    return 0;
}

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

int main(){
  
  int n;

  while(cin>>n && n){
    int nmax=0,nmin=100000,s,ans=0;
    for(int i=0;i<n;i++){
      cin>>s;
      ans+=s;
      nmax=max(nmax,s);
      nmin=min(nmin,s);
    }
    cout<<(ans-nmax-nmin)/(n-2)<<endl;
  }

  return 0;
}

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

#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  vector<int> a;

  while(true){
    vector<int> a;
    cin >> N;

    if(N == 0) break;

    int b;
    REP(i, N) {
      cin >> b;
      a.push_back(b);
    }

    sort(a.begin(), a.end());

    int sum = 0;
    FOR(i, 1, N - 1) {
      sum += a[i];
    }
    sum = sum / (N - 2);
    
    cout << sum << endl;

  }




}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <stack>

using namespace std;


int main(){
	int n;

	while(1){
		cin >> n;
		if(n == 0) break;

		int score[n];
		for(int i=0 ; i<n ; i++){
			cin >> score[i];
		}
		sort(score , score+n);
		
		int sum=0;
		for(int i=1 ; i<n-1 ; i++){
			sum += score[i];
		}
		sum = sum / (n-2);

		cout << sum << endl;
	}
	return 0;
}

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

int main()
{
	int x[20], y, i, j, n, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	sort(x,x+n);
	for (i = 1; i < n - 1; i++)
	{
		sum += x[i];
	}
	cout << sum / (n - 2);
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define EPS 1e-9
using namespace std;

template <class T>
static T read()
{
	T t;
	cin >> t;
	return t;
}

template <class T>
static vector<T> read_n(int n)
{
	vector<T> v;
	REP(i,n) { v.push_back(read<T>()); }
	return v;
}

template <class T>
static void write(const T &t)
{
	cout << t << endl;
}

/// template end ///

int main()
{
	while (true)
	{
		int n = read<int>();
		if (!n) { break; }
		vector<int> v = read_n<int>(n);
		sort(ALLOF(v));
		int ret = accumulate(v.begin() + 1, v.end() - 1, 0) / (n - 2);
		write(ret);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

namespace Math {
    ll modpow(ll b, ll p, ll m) {
        ll r = 1;
        for (; p; p >>= 1, b = b * b % m)
            if (p & 1)
                r = r * b % m;
        return r;
    }

    ll modinv(ll b, ll m) { return modpow(b, m - 2, m); }

    // Least significant bit.
    ll lsb(ll x) { return x & (-x); }

    template <class T> const T inf() { return 0; }
    template <> const ll inf<ll>() { return 0x3f3f3f3f3f3f3f3fll; }
    template <> const int inf<int>() { return 0x3f3f3f3f; }

    template <class T> T gcd(T a, T b) { return abs(__gcd(a, b)); }
    template <class T> T clamp(T n, T l, T r) { return n < l ? l : n > r ? r : n; }
    template <class T> T lcm(T a, T b) { return abs(a / gcd(a, b) * b); }
    template <class T> T sgn(T n) { return n == 0 ? 0 : n > 0 ? 1 : -1; }

    // Generic modular integer.
    template<int MOD, typename IntType = int>
    struct GModint {
        IntType val;

        GModint() : val(0) {}

        GModint(int v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        GModint(ll v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        explicit operator bool() const { return val != 0; }

        const bool operator==(const GModint &g) const { return val == g.val; }

        const bool operator!=(const GModint &g) const { return val != g.val; }

        const GModint operator+=(const GModint &g) { return *this = *this + g; }

        const GModint operator-=(const GModint &g) { return *this = *this - g; }

        const GModint operator*=(const GModint &g) { return *this = *this * g; }

        const GModint operator/=(const GModint &g) { return *this = *this / g; }

        const GModint operator^=(const GModint &g) { return *this = *this ^ g; }

        const GModint operator-() const { return GModint(val == 0 ? 0 : MOD - val, true); }

        const GModint operator+(const GModint &g) const {
            ll newval = val + g.val;
            if (newval >= MOD)
                newval -= MOD;
            return GModint(newval, true);
        }

        const GModint operator-(const GModint &g) const { return *this + (-g); }

        const GModint operator*(const GModint &g) const { return GModint(1ll * val * g.val); }

        const GModint operator/(const GModint &g) const { return *this * g.inv(); }

        template<class T>
        const GModint operator^(const T t) const { return GModint(modpow(val, t, MOD)); }

        const GModint inv() const { return GModint(modinv(val, MOD)); }
    };

    using Modint = GModint<1000000007>;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    do {
        int n; cin >> n;
        if (n == 0) break;

        int vmin, vmax, sum = 0;
        for (int i = 1; i <= n; i++) {
            int t; cin >> t;
            sum += t;
            if (i == 1) vmin = vmax = t;
            else vmin = min(vmin, t), vmax = max(vmax, t);
        }

        cout << (sum - vmin - vmax) / (n - 2) << endl;
    } while (true);
}