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 <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}//pは素数,aのb乗をpで割った余り
ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}//pは素数,(nCr)%p
ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	if (a%b == 0)return b;
	return gcd(b, a%b);

}//最大公約数
ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}//最小公倍数

int main() {
	
	while(1){
		int N;
		ll sum=0;
		cin>>N;
		if(N==0)break;
		vector<int> S;
		for(int i=0;i<N;i++){
			int s;
			cin>>s;
			S.pb(s);
			sum+=s;
		}
		sort(S.begin(),S.end());
		cout<<(sum-S[0]-S[N-1])/(N-2)<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n;
    int a[100];
    cin>>n;
    while(n!=0){
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        int sum;
        for(int i=1;i<n-1;i++){
            sum+=a[i];
        }
        cout<<sum/(n-2)<<endl;
        cin>>n;
    }
}

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

int main(){
	int n;
	while(1){
		int sum, result;
		cin >> n;
		if(n == 0){
			break;
		}
		vector<int> score;
		for(int i = 0; i < n; i++){
			int s;
			cin >> s;
			score.push_back(s);
		}
		sort(score.begin(), score.end());
		sum = accumulate(score.begin(), score.end(), 0);
		result = (sum - score[0] - score[n-1]) / (n-2);
		cout << result << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



int main() {
	cout << fixed << setprecision(18);
	long long int n,x[120]={},mymin=INF,mymax=-INF,sum=0;
	cin>>n;
	while(n!=0){
		mymin=INF;mymax=-INF,sum=0;
		for(int i=0;i<n;i++){
			cin>>x[i];
			mymin=min(mymin,x[i]);
			mymax=max(mymax,x[i]);
			sum+=x[i];
		}
		cout<<(sum-mymax-mymin)/(n-2)<<endl;
		cin>>n;
	}
}

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

int main() {
	int n;
	while (1) {
		int sum = 0;
		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());
		for (int i = 1; i < n-1; i++) sum += a[i];
		cout << sum / (n-2) << endl;

	}
}

C++: 
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
using namespace std;
using ll = long long;



int main(){
	int n, s[100];
	int k = 0;
	while (1){
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) cin >> s[i];
		sort(s, s + n);
		for (int i = 1; i < n - 1; i++) {
			k += s[i];
		}
		cout << k / (n-2) << endl;
	}

}

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

using namespace std;

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> s;
    for (int i = 0; i < n; i++) {
      int tmp;
      cin >> tmp;
      s.push_back(tmp);
    }
    sort(s.begin(), s.end());
    int ans = accumulate(s.begin() + 1, s.end() - 1, 0) / (n - 2);
    cout << ans << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> p;
#define le 1000000007;
int main(){
  while(1==1){
  int n;
  cin >> n;
  if(n==0)break;
  long long int sum=0;
  vector<int> v(n,0);
  for(int i=0;i<n;i++){
    cin >> v[i];
    sum+=v[i];
  }
  cout << (sum-max(v[0],v[n-1])-min(v[0],v[n-1]))/(n-2) << endl;
  }
  return 0;
}

C++: # coding: utf-8

import sys

if __name__ == '__main__':
    while 1:
        n = int(input())
        if n == 0:
            break
        a = [int(input()) for i in range(n)]
        print((sum(a) - min(a) - max(a)) // (n-2));

C++: #include <iostream>
using namespace std;
int main(){
  int a[2020];
  int x,i = 0;
  while (cin >> x){
    a[i++] = x;
  }
  void saiten(int* a,int b);
  saiten(a,0);
}
void saiten(int* a,int j){
  int max = 0, min = 0, ave = 0;
  if (a[j] != 0){
    for (int k = j+1; k <= j+a[j]; k++){
      if (max < a[k])
	max = a[k];
      if (min > a[k])
	min = a[k];
      ave += a[k];
    }
    ave = (ave - max - min)/(a[j]-2);
    cout << ave << endl;
    saiten(a, j+a[j]+1);
  }
}

C++: #include <iostream>
using namespace std;
int max(int a, int b) {
	if (b < a) {
		b = a;
	}
	return b;
}
int min(int a, int b) {
	if (b > a) {
		b=a;
	}
	return b;
}
int main() {
	int s, n, t, sum=0, ave, maxi=0, mini=1000;
	while (1) {
		cin >> n;
		if (n == 0)break;
		for (t = 0; t < n; t++) {
			cin >> s;
			sum = sum + s;
			maxi = max(s,maxi);
			mini = min(s,mini);
		}
		sum = sum - maxi - mini;
		ave = sum / (n-2);
		cout << ave << endl;
		maxi = max(0,0), mini = min(1000,1000),sum=0;
	}
	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        int s;
        int sum=0;
        int ma=-1;
        int mi=10000;
        for(int i=0;i<n;i++){
            cin>>s;
            ma=max(ma,s);
            mi=min(mi,s);
            sum+=s;
        }
        sum-=mi+ma;
        cout<<sum/(n-2)<<endl;

    }


}

C++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp*/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;

    while (cin>>n && n>0){
        vector<int> s;

        for (int i=0;i<n;i++){
            int tmp;

            cin>>tmp;
            s.push_back(tmp);
        }
        sort(s.begin(),s.end());
        cout<<accumulate(++s.begin(),--s.end(),0)/(n-2)<<endl;
    }
    return 0;
}