Go: package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		num := nextInt(sc)
		if num == 0 {
			break
		}

		score_list := []int{}
		for i := 0; i < num; i++ {
			score_list = append(score_list, nextInt(sc))
		}
		// 得点リストをソートした後、最低点と最高点を取り除く(3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1 : len(score_list)-1]
		// 得点リストの得点を合計し、スライスの個数で割って平均点を出す
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

int n;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(true){
		cin >> n;
		if(n == 0) return 0;
		vector<int> v;
		for(int i=0; i<n; ++i){
			int t;
			cin >> t;
			v.push_back(t);
		}
		int sum = 0;
		sort(v.begin(), v.end());
		for(int i=1; i<n-1; ++i)
			sum += v[i];
		sum /= n-2;
		cout << sum << "\n";
	}
}

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

int main()
{
    int x;
    while(1){
        cin >> x;
        if(x == 0) break;
        int max = -1, mini = 10000, sum = 0, score = 0, y = 0;
        for(int i = 0; i < x; i++){
           cin >> score;
          sum += score;
          if(score > max) max = score;
            if(score < mini) mini = score;
        }
        sum -= max + mini;
        y = sum / (n - 2);
        cout << y << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int N, S;

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 1001; //min????°?????????¨?????????
    int max = -1;
    int average = -1;

    for (int i = 0; i < N; i++){
      cin >> S;
      sum += S;
      if( S > max ) max = S;
      if(S < min) min = S; 
    }

    average = (sum - min - max) / N - 2; //???N-2?????§???????????¨?????¨??????

    cout << average << endl;
  }

  return 0;
}

C++: import math
import copy

def average(points):
    sum = 0
    for i in points:
        sum += i
    return sum / len(points)

outputs = []

while True:
    num = int(input())
    if num == 0:
        break

    points = []
    for _ in range(num):
        point = int(input())
        points.append(point)

    points = sorted(points)
    points = points[1:len(points)-1]

    ave = average(points)
    outputs.append(int(ave))

for ave in outputs:
    print(ave)

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

int main(){
	int n;
	while(cin >>n){
		if(n == 0) break;
		vector<int> vec;
		int tmp, max, min;
		cin >>tmp;
		vec.push_back(tmp);
		max = tmp;
		min = tmp;
		bool maxb = true, minb = true;
		for(int i = 1; i < n; i++){
			cin >>tmp;
			vec.push_back(tmp);
			if(tmp < max) max = tmp;
			if(tmp > min) min = tmp;
		}
		int sum = 0;
		for(int i = 0; i < vec.size(); i++){
			if(vec[i] == max && maxb){
				maxb = false;
			} else if(vec[i] == min && minb){
			minb =false;
		} else{
			vec[i] += sum;
		}
		cout <<sum <<endl;
		return 0;
	}
}
}

C++: #include<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n, n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << (S-ma-mi)/n << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)


int main()
{
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n)
    {
        if(n == 0)
            return 0;
        vector<int> nums;
        REP(i, n)
        {
            int tmp;
            cin >> tmp;
            nums.push_back(tmp);
        }
        sort(nums.begin(),nums.end());
        int sum = 0;
        RFOR(i, n-1, 1)
            sum += nums[i];
        cout << sum / (n-2) << '\n';
    }
}

C++: #include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int			n;
	int			s_buf;
	int			sum;
	vector<int>	s;

	while(cin >> n){
		if(n == 0){
			break;
		}

		sum = 0;
		s_buf = 0;
		s.clear();

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

			s.push_back(s_buf);
		}

		sort( s.begin(), s.end() );

		for(int i = 1; i < s.size() - 1; i++){
			sum += s[i];
		}

		cout << sum / (s.size() - 2) << endl;
	}
}

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

int main(void){

  int n;
  int s[1000];
  int max,min,sum,ave;

  while(1){

    max=0;
    min=1000;
    sum=0;
    ave=0;

    cin >> n;

    if( n == 0 ) break;

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

      cin >> s[i];

    }

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

      if( max < s[i] ) max = s[i];

      if( min > s[i] ) min = s[i];

      sum+= s[i];

    }

    sum = sum - max - min;
    ave = sum / (n-2);

    cout << ave << endl;

  }

  return 0;

}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(1){
		int a, max=-1, min=100000, sum=0, ans;
		cin >> n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin >> a;
			if(a<min) min=a;
			if(a>max) max=a;
			sum += a;
		}
		ans = (sum-(max+min))/(n-2);
		cout << ans << endl;
	}
}

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

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

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

}
}

C++: #include <stdio.h>
#include <string.h>

int main(void){
	int i, j, point[1001], n, s, sum, cnt;
	scanf("%d",&n);
	while(n != 0){
		memset(point,0,sizeof(point));
		for(i = 0;i < n;i++){
			scanf("%d",&s);
			point[s]++;
		}
		for(i = 0;i <= 1000;i++){
			if(point[i]){
				point[i]--;
				break;
			}
		}
		for(i = 1000;i >= 0;i--){
			if(point[i]){
				point[i]--;
				break;
			}
		}
		sum = 0;
		cnt = 0;
		for(i = 0;i <= 1000;i++){
			for(j = 0;j < point[i];j++){
				sum += i;
				cnt++;
			}
		}
		printf("%d\n",sum / cnt);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore;
int minscore;
int maxnum;
int minnum;
cin >> judge;
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		i=maxnum;
		}
		if(score[i] < minscore){
		minscore = score[i];
		i = minnum;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore += score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n=1,t;
    while(cin>>n,n){
        int num=0,count=0;
        vector<int> v;
        for(int i=0;i<n;i++){
            cin >>t;
            count++;
            v.push_back(t);
            num+=t;
        }
        num -= *max_element(v.begin(),v.end());
        num -= *min_element(v.begin(),v.end());
        int ans=(double)num/(count-2);
        cout<<ans<<endl; 
    }
}

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

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

	while (true) {
		cin >> n;
		sum = max = min = 0;
		if (n == 0)	break;

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