Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

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