Go: package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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

C++: #include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main(){
	int i,j,k,l,m,n;
	while(cin>>n){
		if(n==0) break;
		int mx=0, mn=2000;
		k=0;
		rep(i,n){
			cin >> m;
			mx = max(mx,m);
			mn = min(mn,m);
			k+=m;
		}
		cout << (k-mx-mn)/(n-2) << endl;
	}
}

C++: #include <iostream>

int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int n;
	int score[1024];

	while (true) {
		std::cin >> n;
		if (!n) break;

		for (int i = 0; i < n; i++) std::cin >> score[i];

		qsort(score, n, sizeof(int), compare);
		double sum = 0;
		for (int i = 1; i < n - 1; i++) sum += score[i];
		int ave = int(sum / (n-2));
		std::cout << ave << '\n';
	}
	return 0;
}