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())
		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 < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include <bits/stdc++.h>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	int result[100] = {};
	int pos = 0;
	while (1) {
		int n;
		int s[101] = {};
		int mini = 1001;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		pos++;
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			if (mini > s[i]) {
				mini = s[i];
			}
			total += s[i];
		}
		result[pos] = (total - maxi - mini) / (n - 2);
	}
	FOR(i, 1, pos) {
		cout << result[i] << endl;
	}

}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

int main()
{
	int n;
	int a[100];
	int ans;

	while (1) {
		cin >> n;
		if (n == 0) break;
		ans = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i]; 
		}
		sort(a, a + n);
		for (int i = 1; i < n - 1; i++) {
			ans += a[i];
		}
		ans /= n - 2;
		cout << ans << endl;
	}

	

	return (0);
}

C++: #include<iostream>
using namespace std;
int main(){
while(true){
int n;
if(n == 0)return 0;
cin >> n;
int a[n];
for(int i = 0; i < n; i++)
cin >> a[i];

int max = 1000;
int min = 0;
int sum = 0;

for(int i = 0 ; i <= n ; i++){
	if(a[i] > max)
	max = a[i];
	else if (a[i] < min)
	min = a[i];
	sum += a[i];
}
cout << (sum-max-min)/(n-2);

}
}

C++: #include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	while (cin >> N, N) {
		vector<int> A(N);
		for (int i = 0; i < N; i++) {
			cin >> A[i];
		}
		sort(A.begin(), A.end());
		int sum = 0;
		for (int i = 1; i < N - 1; i++) {
			sum += A[i];
		}
		sum /= (N - 2);
		cout << sum << endl;
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

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

int main()
{
	int a;
	while(scanf("%d",&a)&&a!=0)
	{
		int sum=0;
		int min=1000;
		int max=0;
		for(int i=0;i<a;i++)
		{
			int tmp;
			scanf("%d",&tmp);
			sum+=tmp;
			if(min>tmp) min = tmp;
			if(max<tmp) max = tmp;
		}	
		printf("%d\n",(sum-min-max)/(a-2));
	}
	return 0;
}

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

int main(){
	int n,s,min,max,sum;

	while(cin>>n && n>0){
		max=0;
		sum=0;
		for(int i=0;i<n;i++){
			cin>>s;
			sum+=s;
			if(i==0) min=s;
			if(s>max) max=s;
			if(s<min) min=s;
		}
		cout<<(sum-max-min)/(n-2)<<endl;
	}
}

C++: #include <iostream>

using namespace std;

int main() {
    int scores[7];
    int score_length = 0;
    
    int number = 0;
    cin>>number;
    while (number != 0) {
        int max = 0;
        int min = 1000;
        int score = 0;
        int total = 0;
        for (int i = 0; i < number; i++) {
            cin>>score;
            total += score;
            if (score > max) max = score;
            if (score < min) min = score;
        }
        total -= max + min;
        scores[score_length] = total / (number-2);
        score_length++;

        cin>>number;
    }

    for (int i = 0; i < score_length; i++) {
        cout<<scores[i]<<endl;
    }
}

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

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

C++: #include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;


int main(){

	int n,minimum,maximum,sum,tmp;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		sum = 0;
		minimum = 100000;
		maximum = -1;

		for(int i = 0; i < n; i++){
			scanf("%d",&tmp);
			sum += tmp;
			minimum = min(minimum,tmp);
			maximum = max(maximum,tmp);
		}

		sum -= minimum;
		sum -= maximum;

		printf("%d\n",sum/(n-2));

	}

	return 0;
}