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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    vector<int> a(n);
    REP(i,n)cin>>a[i];
    int s = accumulate(a.begin(),a.end(),0)- *min_element(a.begin(),a.end())
      - *max_element(a.begin(),a.end());
    cout<<s/(n-2)<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
	int a[20];
	int b,sum=0,point;
	while(1){
		cin >> b;
		if(b==0) break;
		for(int i=0;i<b;i++){
			cin >> a[i];
			
		}
		sort(a,a+b);
		for(int j=1;j<b-1;j++){
			sum+=a[j];
		}
		point=sum/(b-2);
		cout << point << endl;
		sum=0;
		
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int n;
int main(){
	while(cin>>n){
		if(n==0)break;
		int s[110]={},ma=0,mi=1001,cn=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			if(s[i]>ma){
				ma=s[i];
			}
			if(s[i]<mi){
				mi=s[i];
			}
			cn+=s[i];
		}
		cout<<((cn-mi)-ma)/(n-2)<<endl;
	}
	return 0;
}

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

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

C++: #include<bits/stdc++.h>
using namespace std;
int main() {

while(true){
     int n;
     cin >> n;
     vector<int> A(n);
  
  if(n>0){
  for(int i=0;i<n;i++){
  
     cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int sum=0;
  for(int i=1;i<n-1;i++){
  sum+=A.at(i);
  }
  cout << sum/(n-2) << endl;
  }
 if(n==0){
    break;
   }
}
}

C++: #include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
    int n;
    int x[21];
    while(1){
        int S=0;

        cin>>n;
        if(n==0){
            break;
        }
        for(int i=0;i<n;i++){
            cin>>x[i];
        }
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(x[i] < x[j]){
                    int temp = x[i];
                    x[i] = x[j];
                    x[j] = temp;
                }
            }
        }
        for(int i=1;i<n-1;i++){
            S=S+x[i];
        }
        int A=0;
        A=S/(n-2);
        cout<<A<<endl;
    }
    return 0;
}

C++: #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  while(true)
  {
    ll n; cin>>n;
    if(n==0) {break;}
    ll m,M,sum=0;
    m=10000;
    M=0;
    rep(i,n)
    {
      ll s; cin>>s;
      sum+=s;
      m=min(m,s);
      M=max(M,s);
    }
    cout<<(sum-M-m)/(n-2)<<endl;
  }  
  return 0;
}

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

C++: #include <iostream>

using namespace std;

int main(void){
  while(1){
    int n;
    cin >> n;
    if(n == 0){return 0;}

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

    int sum = 0;
    int max = -1;
    int min = 1001;
    for(int i = 0 ; i < n ; i++){
      if(max < point[i]){max = point[i];}
      if(min > point[i]){min = point[i];}

      sum += point[i];
    }

    cout << (int)(sum - max - min)/(n - 2);
  }

}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>

using namespace std;

int n;
int s;
vector<int> v;
int f;
int b;
int sum = 0;
int ans = 0;

int main() {

	while (cin >> n) {
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> s;
			v.push_back(s);
		}

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

		f = v[0];
		b = v[v.size() - 1];

		for (int i = 0; i != v.size(); ++i) {
			sum += v[i];
		}
		sum = sum - f - b;
		ans = sum / (v.size() - 2);

		cout << ans << endl;

		v.clear();
		sum = 0;
		ans = 0;

	}
}

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

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

int main(){
        int i = 0;
        
        while(cin >> i && !(i == 0)){
                int a[i];
                int j = 0;              

                for(j=0; j<i; j++){
                        cin >> a[j];
                }
                cout << endl;           
        
                //sum
                int sum = 0;
                for (j=0; j<i; j++) {
                        sum += a[j];
                }
        
                //largest,smallest
                int largest = 0;
                int smallest = 1000;
                for (j=0; j<i; j++){
                        if (a[j] > largest)
                                largest = a[j];
                        else if (a[j] < smallest)
                                smallest = a[j];
                }
                
                //average
                int average = 0;
                average = (sum - largest - smallest) / (i - 2);
                cout << average;
        }
}

C++: 

while true do
    max = -1
    min = 1001
    sum = 0
    n = gets.to_i
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

C++: #include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#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, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
#define MAX 20
using namespace std;

int main(void){
  while(true){
    int n;  cin >> n;
    if(n==0)  break;
    int s[MAX], sum=0;
    rep(i, n) cin >> s[i];
    sort(s, s+n);
    FOR(i, 1, n-1)  sum += s[i];
    cout << sum/(n-2) << endl;

  }
  return 0;
}