Go: package main

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

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

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

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

		score_list := []int{}
		for i := 0; i < num; 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))
	}
}

C++: #include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>

using namespace std;

int main(void) {
	int dataset_num = 0;
	int sum = 0;
	int max = 0;
	int min = 1001;
	int score;
	int j_num;

	cin >> j_num;

	while (j_num != 0 && dataset_num < 20){
		for (int i = 0; i < j_num; i++){
			cin >> score;

			if (score > max) {
				max = score;
			}
			if (score < min) {
				min = score;
			}

			sum += score;
		}

		sum = sum - max - min;
		double ave_score = sum / (j_num-2);
		cout << ave_score << endl;

		cin >> j_num;
		dataset_num++;
		sum = 0;
		max = 0;
		min = 1001;
	}	
	return 0;
}

C++: /*** ICPC??????????¨???????????????§??¢ ***/

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

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

C++: #include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define vi vector<int>
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

const int MOD = 1e9 + 7;
const int INF = 1 << 30;


class UnionFind{
private:
        vector<int> par,rank,sizes;
        int tree;

public:
        explicit UnionFind(const int n) : tree(n){
            par.resize(n+1);
            rank.resize(n+1);
            sizes.resize(n+1);
            rep(i,n){
                par[i] = i;
                sizes[i] = 1;
            }
        }

        ~UnionFind() = default;

        int root(int x){
            if(par[x] == x) return x;
            else return par[x] = root(par[x]);
        }

        int find(int x){ return root(x);}

        void unite(int x, int y) {
            x = root(x);
            y = root(y);
            if (x == y) return;

            if (rank[x] < rank[y]) swap(x, y);
            par[y] = x;
            tree--;
            sizes[x] += sizes[y];
            if (rank[x] == rank[y]) rank[x]++;
        }

        bool same(int x, int y){
            return root(x) == root(y);
        }

        int size(int x){
            return sizes[x];
        }

        int sumTree(){
            return tree;
        }
};

template <typename T>
class segmentTree{
private:
    int n;
    vector<T> arr;
public:

    explicit segmentTree(vector<T> v){
        ll sz = v.size();
        //while()

        arr.resize(2*n - 1);

    }

    T &operator[](int n){ return arr[n];}


};

template <int mod>
class ModInt{
private:
    ll _num;

public:
    ModInt(){_num = 0;}
    explicit ModInt(ll value){_num = value%mod;}

    ModInt operator+(ModInt &x){ return ModInt(_num + x._num);}
    ModInt operator-(ModInt &x){ return ModInt(_num - x._num);}
    ModInt operator*(ModInt &x){ return ModInt(_num * x._num);}
    friend ostream &operator<<(ostream &os, const ModInt &x){os<<x._num; return os;}
    friend istream &operator>>(istream &is, ModInt &x){is>>x._num; return is;}
};
using mint = ModInt<MOD>;


class topos{

};

int gcd(int a,int b){
    return b ? gcd(b,a%b) : a;
}

ll power(ll m, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = ((res%mod) * (m%mod))%mod;
        m = (m * m)%mod;
        n >>= 1;
    }
    return res;
}


int main() {
    while(true){
        int n; cin >> n;

        if(n == 0) break;

        vi a(n);
        rep(i,n){
            cin >> a[i];
        }

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

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

}

C++: #include<iostream>
using namespace std;
main(){
  int n,count=0,s,maxs,mins;
  while(1){
    cin>>n;
    if(n==0)break;
    cin>>s;
    count=count+s;
    maxs=s;
    mins=s;
    for(int i=1;i<n;i++){
      cin>>s;
      count=count+s;
      if(s>maxs){
	maxs=s;
      }
      else if(mins>s){
	mins=s;
      }
    }
    cout<<(count-maxs-mins)/(n-2)<<endl;
    count=0;
  }
}

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

void doit(int N) {
    if (N < 3) {
        return;
    }
    int min = std::numeric_limits<int>::max();
    int max = std::numeric_limits<int>::min();
    int total = 0;
    int num = 0;
    
    for (int i = 0; i < N; i++) {
        int v;
        std::cin >> v;
        if (v < min) {
            min = v;
        }
        if (v > max) {
            max = v;
        }
        total += v;
        num++;
    }
    total -= (min + max);
    num -= 2;
    std::cout << (int)(((double)total) / num) << std::endl;
}

int main()
{
    int N;
    while(std::cin >> N) {
        doit(N);
    }
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
if(judge != 0){
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

C++: #pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

signed main(void)
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);

    while(true){
        int N;
        cin>>N;
        if(N==0) return 0;
        vector<int> V(N);
        for(int i=0;i<N;i++) cin>>V[i];
        sort(V.begin(),V.end());
        int sum=0;
        for(int i=1;i<N-1;i++) sum+=V[i];
        cout<<sum/(N-2)<<endl;
    }
}