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>
using namespace std;

int main(void) {
	int n, sum, max, min, ave,a,total;
	int i,num;

	for (;;) {
		sum = 0;
		min = 1000;
		max = 0;
		cin >> n;
		if (n == 0) {
			break;
		}
		for (i = 0; i < n; i++) {
			cin >> a;
			sum += a;
			if (max < a) {
				max = a;
			}
			if (min > a) {
				min = a;
			}

		}

		total = sum - max - min;
		num= n - 2;

		ave = total / num;

		cout << ave << endl;

	}

	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	for (;;) {
		int n; cin >> n;
		if (!n) break;

		vector<int> v(n);
		rep(i, 0, n) cin >> v[i];
		sort(all(v));
		int ans = 0;
		rep(i, 1, n - 1) ans += v[i];
		cout << ans / (n - 2) << endl;
	}
}

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


int main(){
	int num = 0;
	while (cin >> num){
		if (num == 0)return 0;
		vector<int> vec;
		int temp;
		while (cin >> temp){
			vec.push_back(temp);
		}
		sort(vec.begin(),vec.end());
		vec.pop_back();
		reverse(vec.begin(), vec.end());
		vec.pop_back();
		int ave = 0;
		for (int i = 0; i < vec.size(); i++)
			ave += vec[i];
		ave /= vec.size();
		cout << ave << endl;
	}
	return 0;
}

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

int n;

int main()
{
  while (cin >> n, n) {
    vector<int> v = vector<int>(n);
    for (int i = 0; i < n; i++)
      cin >> v[i];
    sort(v.begin(), v.end());

    int sum = accumulate(v.begin(), v.end(), -(v[0]+v[v.size()-1]));
    cout << (sum / (v.size()-2)) << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
bool b[33000];
int main() {	
	int n;
	while (cin >> n&&n) {
		int a=10000000, b=-100,x;
		long long sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> x;
			sum += x;
			a = min(a, x);
			b = max(b, x);
		}
		sum -= a;
		sum -= b;
		double c = floor((double)sum / (double)(n - 2));
		cout << c << endl;
	}
}

C++: #include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;

int main() {
	while(1) {
		int n, add = 0, max = 0, min = 1000, s, avg;
		cin >> n;
		if(n == 0) break;
		for(int i = 0; i < n; i++) {
			cin >> s;
			if(s <= min) min = s;
			if(s >= max) max = s;
			add += s;
		}
		cout << (add - max - min)/ (n-2) <<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define  rep(i,n) for (int i=0;i<n;i++)
using namespace std;

int main(){
    while (true){

        int n;
        cin>>n;
        if (n==0) break;
        vector<int> v(n,0);
        int sum=0;
        rep(i,n) {
            cin>>v[i];
            sum+=v[i];
        }
        sort(v.begin(),v.end());
        cout<<(sum-v[0]-v[n-1])/(n-2)<<endl;

    }
    return  0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    while(true){
        int n; cin >> n;
        if(n == 0){
            break;
        }
        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];
        }
        cout << sum / (n-2) << endl;
    }
}

C++: #include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<utility>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int dt[n];
    rep(i,n){
      cin>>dt[i];
    }
    int sum=0;
    sort(dt,dt+n);
    dt[0]=dt[n-1]=0;
    rep(i,n){
      sum+=dt[i];
    }
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

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

using namespace std;

void remove_minmax(vector<int> &data){
  int max = 0;
  int min = 1000000;
  int min_i = 0;
  int max_i = 0;
  int count = 0;
  vector<int>::iterator it = data.begin();
  while (it != data.end()){
    if (*it < min){
      min = *it;
      min_i = count;
    }
    if (*it > max){
      max = *it;
      max_i = count;
    }
    ++count;
    ++it;
  }
  data[max_i] = 0;
  data[min_i] = 0;
}

int main(void){
  int n;
  while (cin >> n){
    if (n == 0){
      return -1;
    }
    
    vector<int> data;
    
    for (int i=0; i<n; ++i){
      int num;
      cin >> num;
      data.push_back(num);
    }
    remove_minmax(data);

    int total = floor((double)accumulate(data.begin(), data.end(), 0)/(n-2));
    cout << total << endl;
  }
  return 0;
}

C++: 
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>
long long int D[10000];
long long int E[400000];

using namespace std;
int main() {
	long long int N;
	long long int Y = -1;
	cin >> N;
	while (N) {
		Y++;
		for (long long int i = 0; i < N; i++) {
			cin >> D[i];
		}

		sort(D, D + N);
		long long int W = 0;
		for (long long int i = 1; i < N-1; i++) {
			W += D[i];
		}
		E[Y] = W / (N-2);
		cin >> N;
		
	}

	for (long long int i = 0; i <=Y ;i++) {
		cout << E[i] << endl;
	}
	return 0;
}

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

int N;
vector<int> scores;
int judge;

int main()
{
        while(cin >> N){
                if(N==0) break;
                int sum = 0;
                for(int i=0;i<N;i++){
                        cin >> judge;
                        scores.push_back(judge);
                }

                sort(scores.begin(),scores.end());
                scores.erase(scores.begin());
                scores.erase(scores.end()-1);
                for(int i=0;i<N-2;i++){
                        sum += scores[i];
                }
                cout << sum/scores.size() << endl;
                scores.clear();
        }

        return 0;
}

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

int main() {
  int n;

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

C++: //
//  main.cpp
//  no.1
//
//  Created by MacBook_Virgo on 2015/04/23.
//  Copyright (c) 2015??´ MacBook_Virgo. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    while(cin >> n,n!=0){
    int max,min;
    max = 0;
    min = 1000;
    int x;
    int sum = 0;
    for(int i = 0;i <n;i = i+1){
        cin >> x;
        sum = sum + x;
        if(x >max){
            max = x;}
        if(x < min){
            min = x;}
    }
    cout << (sum - max - min) / (n-2) << endl;
    }return 0;
}