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 <cstdio>
#include <cstdlib>
//#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int n;
	while (cin >> n, n){
		priority_queue<int> result;

		for (int i = 0; i < n; i++){

			int buff; cin >> buff;
			result.push(buff);

		}
		
		long int num = 0;
		int i = 0;
		int buff = 0;

		result.pop();
		buff = result.top();
		result.pop();
		while (!result.empty()) {
			num += buff;
			buff = result.top();
			result.pop();
			i++;
		}

		cout << num / i << endl;
		
	}

	return 0;
}