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

using namespace std;

const int INF = 100000000;

int main(){
	int size;
	while(cin >> size,size!=0){
		//sizeに標準入力して、その値が0でない間ループ
		//while(cin >> size,size)と書く人のほうが多い(意味は同じ)。ソースを読むときの参考に
		//scanfを使う場合はcin >> size の部分をscanfで入力するようにすればよい。
		int maxv = -INF;
		int minv = INF;
		int sum = 0;
		for(int i=0;i<size;i++){
			int num;
			cin >> num;
			sum+=num;
			maxv = max(maxv,num);
			minv = min(minv,num);
		}
		int result = (sum-minv-maxv)/(size-2);
		cout << result << endl;
	}
}

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

using namespace std;

int main(void) {
		for (;;) {
			int n;
			scanf("%d", &n);
			if (n == 0) { break; }

			int s_max = 0;
			int s_min = 100000000;
			int sum = 0;

			for (int i = 0; i < n; i++) {
					int s;
					scanf("%d", &s);

					sum += s;
					s_max = max(s, s_max);
					s_min = min(s, s_min);
			}

			sum -= s_max;
			sum -= s_min;

			printf("%d\n", sum / (n - 2));
		}
		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++: #include<iostream>
using namespace std;

int main()
{
    int a,b[100];
    cin>>a;
    int max=0,min=1000,sum=0,result=0;
    for(int i=0;i<a;i++){
        cin>>b[i];
        sum+=b[i];
        if(b[i]<min){
            min=b[i];
        }
        if(b[i]>max){
            max=b[i];
        }
    }
    result=sum-min-max;
    cout<<result/(a-2);
    return 0;
}

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

int main(void)
{
	int data[101];
	int n;
	int sum;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			scanf("%d", data + i);
		}
		std::sort(data, data + n);
		sum = 0;
		for (int i = 1; i < n - 1; i++){
			sum += data[i];
		}
		printf("%d\n", sum / (n - 2));
	}
	return (0);
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,s[100],ave,flag1,flag2;
  bool a,b;
  while(cin >>n && n!=0){
    a=false;b=false;
    flag1=0;flag2=0;
    ave=0;
    for(int i=0;i<n;i++) cin >>s[i];
    sort(s,s+n);

    if(s[0]==s[1]){
      a=true;
    for(int i=1;i<n;i++){
      if(s[0]==s[i]){
	flag1++;
	s[i]=0;}
      else break;
    }
    }
    else if(s[0]==s[1])
    if(s[n-1]==s[n-2]){
	b=true;
    for(int i=n-2;i>=0;i--){
      if(s[n-1]==s[i]){
	flag2++;
	s[i]=0;}
      else  break;
    }
    }

  for(int i=1;i<n-1;i++) ave+=s[i];
  if(a==true){
    n-=flag1;
    ave+=s[0];}
    else n-=1;
  if(b==true){
    n-=flag2;
    ave+=s[n-1];}
    else n-=1;
    ave/=n;
    cout <<ave<<endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
  while(true){
    int n;
    vector<int> a;
    cin >> n;
    if(n==0) break;
    rep(i,n){
      int b;
      cin >> b;
      a.push_back(b);
    }
    sort(a.begin(),a.end());
    int total=0;
    repi(i,1,n-1){
      total+=a[i];
    }
    cout << total/(n-2) << endl;;
  }
  return 0;
}

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

int main()
{
    for(int j=0;j<20;j++){
    int n,sum=0;
    cin >> n;
    if(n==0){
        break;
    }
    vector<int> score(n);
    for(int i=0;i<n;i++){
        cin >> score.at(i);
    }
    sort(score.begin(),score.end());
    for(int i=1;i<n-1;i++){
        sum+=score.at(i);
    }
    cout << sum/(n-2) << endl;
    }
    return 0;
}

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

int main()
{
	int N, d[1000];
	while(cin >> N, N)
	{
		for(int i=0; i<N; i++)
			cin >> d[i];

		sort(d,d+N);
		int ret=0;
		for(int i=1; i<N-1; i++)
			ret+=d[i];

		cout << ret/(N-2) << endl;
	}
}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int n;
	while(scanf("%d",&n),n) {
		int s,sum=0,min_s=1<<30,max_s=0;
		for(int i=0;i<n;i++) {
			scanf("%d",&s);
			sum+=s;
			min_s=min(min_s,s);
			max_s=max(max_s,s);
		}
		printf("%d\n",(sum-min_s-max_s)/(n-2));
	}
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define int int64_t

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

constexpr int dx[4] = { 1, 0, -1, 0 };
constexpr int dy[4] = { 0, 1, 0, -1 };

template<typename STL> inline void print_STL(STL c, string ab = ""){
	cout << ab << '\n';
	for(auto t : c) cout << t << ' '; cout << '\n';}

template<typename VEC> inline void import_VEC(VEC& c, int n){
	typename VEC::value_type tmp;
	for(int i = 0; i < n; ++i){	cin >> tmp; c.push_back(tmp);} }

#define SPRE(x) setprecision(x) // 精度を指定

template<class T>	using Matrix = vector<vector<T>>;

signed main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	while(cin >> n)
	{
		if(n == 0)
			return 0;
		int maxi = 0, mini = INF;
		int sum = 0;
		REP(i, 0, n)
		{
			int tmp;
			cin >> tmp;
			sum += tmp;
			if(maxi < tmp)
				maxi = tmp;
			if(mini > tmp)
				mini = tmp;
		}
		sum -= maxi + mini;
		cout << sum / (n-2) << endl;;
	}

}

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

int main(){
    while (1){
	int n;
	vector<int> s;
	
	cin >> n;
	if (n == 0) break;
	int t;
	for (int i = 0; i < n; i++){
	    cin >> t;
	    s.push_back(t);
	}
	sort(s.begin(), s.end());

	int score = 0;
	for (int i = 1; i < s.size() - 1; i++){
	    score += s[i];
	}
	score /= s.size() - 2;

	cout << score << endl;
    }
}

C++: #include<bits/stdc++.h>
#define SIZE 100005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,s[105];

int main(){
	cin >> n;
	for(int i=0;i<n;i++) cin >>s[i];
	sort(s,s+n);
	int sum=0,m=0;
	for(int i=1;i<n-1;i++) sum+=s[i];
	sum=sum/(n-2);
	cout <<sum<<endl;
	return 0;
}

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

int main()
{
    int n;
    while (cin >> n, n)
    {
        int a[n];
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }

        sort(a, a + n);

        int sum = 0;
        for (int i = 1; i < n - 1; i++)
        {
            sum += a[i];
        }

        cout << sum / (n - 2) << "\n";
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  long long N,ans=0;
  while(cin>>N,N){
    ans=0;
  vector<long long> v(N);
  rep(i,N){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  for(int i=1;i<N-1;i++)ans+=v[i];
  cout<<ans/(N-2)<<endl;
  }
 return 0;
}