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 <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

struct CONTEST_DATA{
	int judgements;
	vector< int > points;
};

int main( void ){

	vector< CONTEST_DATA > contests;
	vector< int > answers;

	while( true ){
		CONTEST_DATA cd;
		cin >> cd.judgements;
		if( cd.judgements == 0 ){
			break;
		}
		int point;
		for( int i = 0; i < cd.judgements; i++ ){
			cin >> point;
			cd.points.push_back( point );
		}
		contests.push_back( cd );
	}

	for( int i = 0; i < contests.size(); ++i ){
		sort( contests[ i ].points.begin(), contests[ i ].points.end() );
	}
	for( int i = 0; i < contests.size(); ++i ){
		auto p = contests[i].points.begin();
		contests[ i ].points.erase( p );
		p = contests[ i ].points.end() - 1;
		contests[ i ].points.erase( p );
	}

	for( int i = 0; i < contests.size(); ++i ){
		int answer = 0;
		for( int l = 0; l < contests[ i ].points.size(); ++l ){
			answer += contests[ i ].points[ l ];
		}
		cout << answer / ( contests[ i ].judgements - 2 )<< endl;
	}

	return 0;
}

C++: #include <iostream>

int main() {
	while (true) {
		int referee;
		std::cin >> referee;
		if (referee == 0) {
			break;
		}

		int max, min;
		std::cin >> max >> min;
		if (max < min) {
			std::swap(min, max);
		}
		int total = 0;
		for (int i = 2; i < referee; ++i) {
			int score;
			std::cin >> score;
			if (max < score) {
				total += max;
				max = score;
			} else if (min > score) {
				total += min;
				min = score;
			} else {
				total += score;
			}
		}
		std::cout << (total / (referee - 2)) << std::endl;
	}
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	vector<int>a;
	int n, k, t;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	while(true) {
		a.clear();
		scanf("%d", &n);
      if(n==0)return 0;
		f(i, n) {
			scanf("%d", &x);
			a.push_back(x);
		}
		sort(a.begin(), a.end());
      s=0;
		f(i, n-2) {
			s += a[i + 1];
		}
		ans = s / (n - 2);
		printf("%d\n", ans);
	}



	return 0;
}

C++: import java.util.Scanner;
public class Main{
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		for(int i=0;i>-1;i++){
			int num=sc.nextInt();
			if(num==0){
				break;
			}else{
			int ave=0;
			int max=0;
			int min=1000;
			int sum=0;
				int[] score =new int[num];
				//Input scores
				for(int j=0;j<num;j++){
					score[j]=sc.nextInt();
					if(score[j]>max){
						max=score[j];
					}else if(score[j]<min){
						min=score[j];
					}
					sum+=score[j];
					ave=(sum-max-min)/(num-2);
				}

					System.out.println(ave);
				}
		}
	}
}

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

int main()
{
  int n;
  int kazu=0,sum=0;
  int max,min;

  while(1)
    {
      cin >> n;

      if(n == 0)break;

      sum = 0;

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

	  if(i == 0)
	    {
	      max = kazu;
	      min = kazu;
	    }

	  if(max < kazu) max = kazu;

	  if(kazu < min) min = kazu;
	}
      sum = sum - max - min;

      cout << sum/(n-2) << endl;
    }
}

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

int main() {
int i,n,x,y,a[20],ans;
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		x = 0;
		y = 0;
		for(i=0;i<n;i++){
		if(a[x] < a[i])x = i;
		if(a[y] > a[i])y = i;
		}
		ans = 0;
		for(i=0;i<n;i++){
			if(i == x)continue;
			if(i == y)continue;
			ans += a[i];
		}
		ans = ans / (n-2);
		printf("%d\n",ans);
	}
	return 0;
}

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

int main(){
  int flag = 1;
  int n,x;
  cin >> n;
  if(n==0) return 0;
  while(flag){
    int max = -1;
    int min = 1001;
    int sum = 0;
    for(int i=0;i<n;i++){
      cin >> x;
      if(x >= max){
        //sum += max;
        max = x;
      }//else sum += x;
      if(x <= min){
        //sum += min;
        min = x;
      }/*else*/ sum += x;
    }
//    sum -= 1000;
    sum = sum - min - max;
    sum = sum / (n - 2);
    cout << sum << endl;
    cin >> n;
    if(n == 0) flag = 0;
  }
  return 0;
}

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

int main(){
	int num;
	int score[105];
	int max = 0;
	int min = 10000;
	int sum=0;


	while(1){
		max = 0; min = 10000; sum = 0;
		for(int i=0; i < 100; i++){score[i] = 0;}

		cin >> num;

		if(num == 0) break;

		for(int i=0; i < num; i++){
			cin >> score[i];
			if(max <= score[i]) max = score[i];
			if(score[i] <= min) min = score[i];
			sum += score[i];
		}

		sum -= max; sum -= min;

		cout << sum/(num-2) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

int main()
{
	vector<int>sums;
	vector<int>mis;
	vector<int>mas;
	vector<int>ns;
	while (true)
	{
		int n; cin >> n;
		if (n == 0)break;
		int tmp;
		int mi = 1000;
		int ma = 0;
		int sum = 0;
		rep(i, n)
		{
			cin >> tmp;
			chmin(mi, tmp);
			chmax(ma, tmp);
			sum += tmp;
		}
		mis.push_back(mi);
		mas.push_back(ma);
		sums.push_back(sum);
		ns.push_back(n);
	}
	rep(i, sz(sums))
	{
		int ans = (sums[i] - mis[i] - mas[i]) / (ns[i] - 2);
		co(ans);
	}
	return 0;
}

C++: #include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
    int n;
   int x[21];
   while(1){
       int max=-1,min=1001;
       int S=0;
       cin>>n;
       if(n==0){
           break;
       }
       for(int i=0;i<n;i++){
            cin>>x[i];
            if(min>x[i]){
                min=x[i];
            }
            if(max<x[i]){
                max=x[i];
            }
           S=S+x[i];            
       }
       S=S-(max+min);
       int A=0;
       A=S/(n-2);
       cout<<A<<endl;
   }
   return 0;
}

C++: #include<iostream>
using namespace std;
int N, S;
int main(){
	while(cin>>N && N>0) {
		int sum=0, large=0, small=1000;
		for(int i=0;i<N;++i){
			cin>>S;
			sum+=S;
			if(large<S) large=S;
			if(small>S) small=S;
		}
		sum=sum-large-small;
		cout<<sum/(N-2)<<endl;
	}
}