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 <bits/stdc++.h>

using namespace std;

int main(void){
	int n,i,s,b,w,ans;
	while(true){
		scanf("%d",&n);
		if(n==0){break;}
		ans = 0;
		b = -1;
		w = 1001;
		for(i=0; i<n; i++){
			 cin >> s;
			 b = max(s,b);
			 w = min(s,w);
			 ans += s;
		}
		ans -= b;
		ans -= w;
		cout << (ans/(n-2)) << endl;
	}
	return 0;
}

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

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<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=1;
  while(N){
  cin >>N;
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
  cin>>N;
}
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000



int main(){

  while(true){
    int n;
    cin >> n;

    if(n==0) break;

    int sum=0, a=INF, b=-1; //a:min, b:max

    rep(i,n){
      int s;
      scanf("%d",&s);
      sum += s;
      a=min(a,s);
      b=max(b,s);
    }
    sum=(sum-a-b)/(n-2);

    cout << sum << endl;

  }

}

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 0;
    }
    
    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 <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

typedef vector<int> Ivec;
int main() {
	int n;
	
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			return 0;
		int Sum = 0, Max = -1, Min = 1001, num[2];
		for (int i = 0; n > i; i++) {
			int buf;
			scanf("%d", &buf);
			if (buf > Max) {
				Max = buf;
				num[0] = i;
			}
			if (buf < Min) {
				Min = buf;
				num[1] = i;
			}
			Sum += buf;
		}
		printf("%d\n", (int)((Sum - (num[0] == num[1] ? Max : Max+Min))/(n- (num[0] != num[1]) - 1)));
	}
	return 0;
}

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

int main(){
	int n, ma, mi, tmp, ans;
	while(cin >> n){
		if(n == 0) break;
		ma = 0;
		mi = 1001;
		ans = 0;
		for(int i = 0;i<n;i++){
			cin >> tmp;
			ans += tmp;
			mi = fmin(tmp,mi);
			ma = fmax(tmp,ma);
		}
		cout << int(ans - mi - ma)/(n-2) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
  int n,s,i,min=1000,max=0,sum=0,ave;
  while(1){
    scanf("%d",&n);
    if(3<=n&&n<=100){ 
      for(i=1;i<=n;i++){
     scanf("%d",&s);
      if(s<min){
    min=s;
      }
      if(s>max){
    max=s;
      }
      sum=sum+s;
   }
      sum=sum-max-min;
      ave=sum/(n-2);
      printf("%d\n",ave);
    }
    else if(n==0){
      break;
    }   
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int n;
	while ( cin >> n, n ) {
		int m = 10000, M = 0, sum = 0;
		for (int i = 0; i < n; ++i) {
			int v; cin >> v;
			sum += v;
			m = min(m, v);
			M = max(M, v);
		}
		cout << (sum - m - M) / (n-2) << endl;
	}
}

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

int main(){
  int a[101];
  int b[20];
  int n = 0;
  int i = 0;
  int max = 0;
  int min = 1000;
  int sum = 0;
  int counter = 0;
  while(1){
    max = 0;
    min = 1000;
    sum = 0;
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> a[i];
      if(max <= a[i]) max = a[i];
      if(min >= a[i]) min = a[i];
      sum += a[i];
    }
    b[counter] = (sum - max - min) / (n - 2);
    counter++;
  }
  for(i=0;i<counter;i++){
    cout << b[i];
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n, x, mx ,mn;
  int a[100] = {};
  double Sum,Sum2,Sum3;
  int Sum4;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++)cin >> a[i];
    mx = a[0];
    mn = a[0];
    for(int i=0;i<n;i++){
      mx = max(mx,a[i]);
      mn = min(mn,a[i]);}
    Sum = 0;
    for(int i=0;i<n;i++) Sum += a[i];
    Sum2 = Sum - mx - mn;
    Sum3 = Sum2 / (n-2);
    Sum4 = Sum3;
    cout <<  Sum4 << endl;
    for(int i =0; i<n;i++)a[i] = 0;
    

  }

  return 0;
}