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

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

C++: //a
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

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

C++: #include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int n;
int s[110];


signed main(){
    while(cin >> n, n > 0){
        rep(i, 0, n) cin >> s[i];
        int a = accumulate(s, s+n, 0LL);
        a -= *max_element(s, s+n);
        a -= *min_element(s, s+n);
        cout << a/(n-2) << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    while( n > 0){
        vector<int> v(n);
        for(int i = 0; i < n; ++i){
            cin >> v[i];
        }
        int max_ = *max_element(v.begin(), v.end());
        int min_ = *min_element(v.begin(), v.end());
        int min_cnt = 0;
        int max_cnt = 0;
        int cnt = 0;
        long long sum = 0;
        for(int j = 0; j < n; ++j){
            int s = v[j];
            if(s == max_) {
                max_cnt++;
            } else if(s == min_) {
                min_cnt++;
            } else {
                sum += s;
                cnt++;
            }
        }
        if(max_cnt > 1) {
            sum += max_;
            cnt++;
        }
        if(min_cnt > 1) {
            sum += min_;
            cnt++;
        }

        cout << (sum/cnt) << endl;
        cin >> n;
    }
}

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

int main(){
	int n;
	while(1){
		int a[100]={0};
		int sum=0;
		cin>>n;
		if(n==0) break;
		for(int i=0 ; i<n ; i++){
			cin >> a[i] ;
		}
		for(int i=n-1 ; i>=0 ; i--){
			for(int j=0 ; j< i ; j++){
				if(a[j]>a[j+1]){
					a[j]^=a[j+1];
					a[j+1]^=a[j];
					a[j]^=a[j+1];
				}
			}
		}
		for(int i=1 ; i<n-1 ; i++){
			sum+=a[i];
		}
			cout << sum/(n-2) << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n && n)
	{
		vint v(n);
		rep(i, n)
			cin >> v[i];

		cout << (accumulate(ALL(v), 0) - *max_element(ALL(v)) - *min_element(ALL(v))) / (n - 2) << endl;
	}
}

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

int main(){
	int n,s,sum,min,max;
	refrain:
	cin>>n;
	if(n==0) return 0;
	min=1001;
	max=-1;
	sum=0;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s>max) max=s;
		if(s<min) min=s;
		sum+=s;
	}
	sum-=max+min;
	sum/=n-2;
	cout<<sum<<endl;
	goto refrain;
}

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

using namespace std;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }

        int sum{0};
        int max_{-1};
        int min_{10000};
        for (int i = 0; i < n; ++i) {
            int s;
            cin >> s;
            sum += s;
            max_ = max(max_, s);
            min_ = min(min_, s);
        }
        cout << ((sum - max_ - min_) / (n - 2)) << endl;
    }
}