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>
                                                                                                                                                                                                                                                    using namespace std;
                                                                                                                                                                                                                                                    int main() {
                                                                                                                                                                                                                                                        int n, s;
                                                                                                                                                                                                                                                        while (cin >> n && n) {
                                                                                                                                                                                                                                                            int mx = -1;
                                                                                                                                                                                                                                                            int mn = 1001;
                                                                                                                                                                                                                                                            int sum = 0;
                                                                                                                                                                                                                                                            for (int i=0; i<n; ++i) {
                                                                                                                                                                                                                                                                cin >> s;
                                                                                                                                                                                                                                                                sum += s;
                                                                                                                                                                                                                                                                mx = max(mx, s);
                                                                                                                                                                                                                                                                mn = min(mn, s);
                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                            sum = sum - mx - mn;
                                                                                                                                                                                                                                                            cout << sum / (n - 2) << endl;
                                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                                        return 0;
                                                                                                                                                                                                                                                    }