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

int main(){
    int n;
    cin >> n;
    while(n != 0){
        vector < int > s(n);
        int min = 1001;
        int max = -1;
        int total = 0;
        for(int i = 0 ; i < n ; i++){
            cin >> s[i];
            if(s[i] < min){
                min = s[i];
            }
            if(s[i] > max){
                max = s[i];
            }
            total += s[i];
       }

       cout << (total-min-max)/(n-2) << endl;
       cin >> n;
    }
}

C++: 	max=s;
      }
      else if(min>s){
	min=s;
      }
    }
    cout<<(count-max-min)/(n-2)<<endl;
    count=0;
  }
}

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

using namespace std;

int main(void){
	while(1){
		int n; cin >> n;
		if(!n) break;

		int smin= 9999, smax=-1, sum = 0;
		for(int i=0; i<n; i++){
			int tmp;
			cin >> tmp;
			sum += tmp;
			smin = min(smin, tmp);
			smax = max(smax, tmp);
		}

		cout << (sum - smin - smax) /(n-2) << endl;


	}
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	vector<int>ans;
	while (1) {
		int n;
		int p[100];
		int p_min = 1000;
		int p_max = 0;
		int sum = 0;
		cin >> n;
		if (n == 0) {
			break;
		}
		rep(i, n) {
			cin >> p[i];
			p_min = min(p_min, p[i]);
			p_max = max(p_max, p[i]);
			sum += p[i];
		}
		sum = sum - p_min - p_max;
		sum /= (n - 2);
		ans.push_back(sum);
	}
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}

	return 0;
}

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 = 1000, ave = 0;  #minは大きいところから
  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>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		sort(Vec.begin(), Vec.end());
		int sum = 0;
		for(int i = 1; i < n - 1; ++i)
		{
			sum += Vec[i];
		}
		cout << sum / (n - 2) << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

int main() {
	int n;
	while(cin >> n, n) {
		int a = 1001;
		int b = -1;
		int sum = 0;
		for(int i = 0; i < n; ++i) {
			int t;
			cin >> t;
			sum += t;
			a = min(a, t);
			b = max(b, t);
		}
		
		sum -= a + b;
		
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	
	int n;

	while(cin>>n){
		int s=0;
		if(n!=0){
			vector<int> a(n);
			for(int i=0;i<n;i++)
				cin>>a[i];
			sort(a.begin(),a.end());
			a[0]=0;
			a[n-1]=0;
			for(int i=0;i<n;i++)
				s+=a[i];
			cout<<s/(n-2)<<endl;
		}
		else
			break;
	}
	
}

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

int main()
{
  while(1)
    {
      int n = 0,mx=-1,mn=1001;
      cin >> n;
      if(n==0)break;
      int avr = 0;
      for(int i=0;i<n;i++)
	{
	  int b;
	  cin >> b;
	  mx =max(b,mx);
	  mn =min(b,mn);
	  avr +=b;
	}
      cout << (avr - mx -mn) /(n -2) << endl;
    }
    


  return 0;
}

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

}

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

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

C++: #include<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n, n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << (S-ma-mi)/(n-2) << std::endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define ll long long
#define INF 1000000000
using namespace std;
int main(){
    int N;
    int s;
    int smax,smin;
    int sum;
    while(1){
        cin >> N;
        if(N==0) return 0;
        smax = 0; smin = INF; sum = 0;
        for(int i=0;i<N;i++){
            cin >> s;
            smax = max(smax,s);
            smin = min(smin,s);
            sum += s;
        }
        sum = sum - smax - smin;
        int ans = sum/(N-2);
        cout << ans << endl;
    }
}

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

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        for (auto& i : v) cin >> i;
        sort(v.begin(), v.end());

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

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

    return 0;
}