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 <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

  while (cin >> n) {
    if (!n) break;

    vector<int> scr(n);
    for (int i=0; i<n; i++) {
      cin >> scr[i];
    }

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

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

  return 0;
}

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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	while(1){
		int n;
		vector<int> vec;
		cin >> n;
		if(n == 0) break;

		for(int i=0; i<n; i++){
			int t;
			cin >> t;
			vec.pb(t);
		}
		sort(vec.begin(), vec.end());

		int ans = 0;
		for(int i=1; i<n-1; i++){
			ans += vec[i];
		}
		ans /= (n-2);

		cout << ans << endl;
	}

	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
  int n;
  while(cin>>n,n!=0){
    vector<int> score(n);
    rep(i,n)cin>>score[i];

    vector<int>::iterator minIt = min_element(score.begin(),score.end());
    int minIndex = distance(score.begin(),minIt);
    score.erase(score.begin()+minIndex-1);

    vector<int>::iterator maxIt = max_element(score.begin(),score.end());
    int maxIndex = distance(score.begin(),maxIt);
    score.erase(score.begin()+maxIndex-1);

    int sum = accumulate(score.begin(),score.end(),0);
    cout << sum/score.size() << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int N;
	const int NMAX = 100;
	int score[NMAX];

	while (1) {
		cin >> N;
		if (N==0) break;
		
		int max, min;
		int sum = 0;
		for (int i=0; i<N; ++i) {
			cin >> score[i];
			sum += score[i];
			if (i == 0) {
				max = min = score[0];
			} else {
				if ( score[i] > max ) max = score[i];
				if ( score[i] < min ) min = score[i];
			}
		}
		cout << (sum-max-min)/(N-2) << endl;

	}

	return 0;
}

C++: int maximum = 0;
    for (int i=1; i<S; ++i)
        for (int j=i; j<S; ++j)
            if (tax(X,i)+tax(X,j) == S) // (*)
              maximum = max(maximum, tax(Y,i)+tax(Y,j));

C++: #include <iostream>
using namespace std;
int larger(int x,int y) {
	int z = 0;
	if (x > y)z = x;
	else z = y;
	return z;
}
int smaller(int x, int y) {
	int z = 0;
	if (x < y)z = x;
	else z = y;
	return z;
}
int main(void) {
	int s = 1;
	while (s == 1) {
		int sinsa, a[100], sum = 0, ave;
		cin >> sinsa;
		if (sinsa == 0)return 0;
		for (int i = 0; i < sinsa; i++) {
			cin >> a[i];
		}
		int n = a[0];
		for (int i = 0; i < sinsa; i++) {
			n = larger(n, a[i]);
		}
		int m = a[0];
		for (int i = 0; i < sinsa; i++) {
			m = smaller(m, a[i]);
		}
		for (int i = 0; i < sinsa; i++) {
			sum += a[i];
		}
		sum = sum - n - m;
		ave = sum / (sinsa - 2);
		cout << ave<<endl;
	}

	return 0;

}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n1;
	cin >> n1;
	int a[100000] = { 0 };
	for (int i = 0; i < n1; i++){
		cin >> a[i];
	}
	sort(a, a + n1);
	a[0] = { 0 };
	a[n1 - 1] = { 0 };
	for (int i2 = 1; i2 < n1; i2++){
		a[0] += a[i2];
	}
cout << a[0] / (n1 - 2) << endl;
	return 0;
}

C++: #include <cstdio>
int main()
{
    int n, s[20], i;
    int max, min, ava, sum;
    while (1)
    {
        max = 0;
        min = 1000;
        sum = 0;
        scanf("%d", &n);
        if (n == 0)
        {
            break;
        }
        for (i = 0; i < n; i++)
        {
            scanf("%d", &s[i]);
            if (max < s[i])
            {
                max = s[i];
            }
            if (min > s[i])
            {
                min = s[i];
            }
            sum += s[i];
        }
        sum -= max;
        sum -= min;
        ava = sum / (n - 2);
        printf("%d\n", ava);
    }
}

C++: #include <iostream>
#include <stdlib.h>
using namespace std;
int N, S;
int main()
{
  while (cin >> N && N > 0){
    if (N<3 || N>100)
      exit (1);
    int sum = 0;
    int largest = 0;
    int smallest =1000;
    for (int i=0; i<N; ++i){
      cin >> S;
      if (S<0 || S>1000)
        exit (2);
      sum += S;
      if (largest < S)
        largest=S;
      if (smallest > S)
      smallest=S;
    }
    int average = 0;
    average = (sum - largest - smallest) / (N - 2);
    cout << average << endl;
  }
}

C++: #include <stdio.h>
int max(int a,int b){
    if(a>b)return a;
    return b;
}
int min(int a,int b){
    if(a>b)return b;
    return a;
}
int main(){
    int n,top,bot,tot,temp;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        scanf("%d",&top);
        tot=bot=top;
        for(int i=1;i<n;i++){
            scanf("%d",&temp);
            tot+=temp;
            top=max(top,temp);
            bot=min(bot,temp);
        }
        printf("%d\n",(tot-top-bot)/(n-2));
    }
}

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

int main(){
  int n,a[21],b[21];
  while(1){
    
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    
    int max=0,min=10001;
    for(int i=0;i<n;i++){
      if(max<a[i]){
	max=a[i];
      }
      if(min>a[i]){
	min=a[i];
      }
    }
    
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=a[i];
    }
    sum-=(max+min);
    
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

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

int main(void){
	int n;
	while(cin>>n,n){
	valarray<int> a(n);
		for(int i=0;i<n;i++)cin>>a[i];
		cout<<(a.sum()-a.max()-a.min())/(a.size()-2)<<endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
 
  while( true ) {
    long long int n;
    long long int a = 0;
    long long int b = 0;
    int input[100];
    cin >> n;
 
    if ( n == 0 ) break;
  
    for ( long long int i = 0; i < n; i++ ) {
 
      cin >> input[i];

      if (input[i] < a)
        a = input[i]

      if (input[i] > b)
        b = input[i] 
    }
 
    long long int ans = 0;
 
    for ( long long int i = 0; i < n; i++ ) {
 
      ans += s[i];
 
    }
 
    cout << (ans - a - b) / ( n - 2 ) << endl;
 
  }
 
  return 0;
 
}

C++: #include <cstdio>
int main()
{
    int n, s[20], i;
    int max, min, ava, sum;
    while (1)
    {
        max = 0;
        min = 1000;
        sum = 0;
        scanf("%d", &n);
        if (n == 0)
        {
            break;
        }
        for (i = 0; i < n; i++)
        {
            scanf("%d", &s[i]);
            if (max < s[i])
            {
                max = s[i];
            }
            if (min > s[i])
            {
                min = s[i];
            }
            sum += s[i];
        }
        sum -= max;
        sum -= min;
        ava = sum / (n - 2);
        printf("%d\n", ava);
    }
    return 0;
}