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

int main(){
    int n;
    while(cin >> n && n > 0){
        int lst[n];
        for(int i=0;i<n;i++){
            cin >> lst[i];
        }
        int max;
        max = lst[0];
        for(int i=1;i<n;i++){
            if(max < lst[i]){
                max = lst[i];
            }
        }
        int min;
        min = lst[0];
        for(int i=1;i<n;i++){
            if(min > lst[i]){
                min = lst[i];
            }
        }
        cout << (accumulate(lst, lst+n, 0) - max - min)/(n-2) << endl;
    }
    return 0;
}

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

int main(){
  int max = 0;
  int min = 0;
  int n = 0;
  int point = 0;
  int sum = 0;
  int summation = 0;

  while(true){
    sum = 0;
    int max = 0;
    int min = 0;
    cin >> n;
    if(n == 0) break;
    //int *s = new int[n];

    for(int i = 0; i < n; i++){
      cin >> point;
      if(i == 0){
        max = point;
        min = point;
      }else{
        if(point >= max) max = point;
        if(point <= min) min = point;
      }
      sum += point;
    }

    summation = sum - max - min;
    cout << summation / (n-2) << "\n";
  }
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  int n;
  while(cin>>n)
  {
    if(n==0) return 0;
    int sum = 0;
    int mx = 0, mn = 9999;
    FOR(i,0,n)
    {
      int in;
      cin>>in;
      sum += in;
      mx = max(mx,in);
      mn = min(mn,in);
    }
    sum -= mx;
    sum -= mn;
    cout << sum/(n-2) << endl;
  }
  return 0;
}

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

using namespace std;

int main() {

    int n;

    while(cin >> n, n) {

        int s[n];
        int ans = 0;

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

        sort(s, s + n);

        for(int i = 1; i < n - 1; ++i) {
            ans += s[i];
        }

        cout << ans / (n - 2) << endl;

    }

}

C++: #include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  int n,tmp;
  for(;;){
    cin>>n;
    if(n==0)return 0;
    multiset<int> s;
    REP(i,n){
      cin>>tmp;
      s.insert(tmp);
    }
    long long int sum=0;
    for(int i:s){
      sum+=i;
    }
    sum-=*(s.begin());
    sum-=*(s.rbegin());
    cout<<sum/(s.size()-2)<<endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

int main(){

	int n;
	
	while(cin >> n, n){
		
		vector<int> vc;
		
		for(int i=0; i<n; ++i){
			int a;
			cin >> a;
			vc.push_back(a);
		}
		
		sort(vc.begin(), vc.end());
		
		int sum = 0;
		
		for(int i=1; i<vc.size()-1; ++i){
			sum += vc[i];
		}
		
		cout << sum/(n-2) << endl;
	}
	
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
//#include<>
using namespace std;

typedef long long int64;
typedef int int32;
typedef char int8;

#define rep(i,j) for(int i=0;i<j;i++)
#define repeat(i,j,k) for(i=(j),i<(k);i++)
#define repeat_eq(i,j,k) for(i=(j),i<=(k);i++)
#define rev_rep(i,j,k) for(i=(j)-1;i>=k;i--)
#define all(v) (v).begin(),(v).end()

const int INF=1<<30;//=10E10

int main()
{
  while(true){
      int n;cin>>n;
      if(n==0)break;
      vector<int> v;
      rep(i,n){
	int t;cin>>t;
	v.push_back(t);
      }
      sort(all(v));
      int ans=0;
      for(int i=1;i<v.size()-1;i++)
	ans+=v[i];
      cout<<ans/(v.size()-2)<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int n, high, low, sum, tmp;
  cin>>n;
  while(n>0) {
    high = 0;
    low = 1000;
    sum = 0;
    for(int i=0; i<n; i++) {
      cin>>tmp;
      sum += tmp;
      if(tmp<low)
	low = tmp;
      if(high<tmp)
	high = tmp;
    }
    sum -= (low+high);
    sum /= (n-2);
    cout<<sum<<endl;
    cin>>n;
  }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int n;
	while(cin>>n){
	int c;
	if(n==0){
		break;
	}
	int ma=0,mi=2000,ans=0;
	for(int i=0;i<n;i++){
		cin>>c;
		ans+=c;
		ma=max(ma,c);
		mi=min(mi,c);
	}
	cout<<(ans-mi-ma)/(n-2)<<endl;
	}
	return 0;
}

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



int main(){
    int N;
    int A[100]={0};
    while (cin >> N && N!=0) {
        int mi_num=10000,ma_num=-1,ave=0,sum=0;
        for (int i=0; i<N; i++) cin >> A[i];
        for (int i=0; i<N; i++) {
            mi_num=min(mi_num,A[i]);
            ma_num=max(ma_num,A[i]);
            sum+=A[i];
        }
        ave=(sum-mi_num-ma_num)/(N-2);
        cout << ave << endl;
    }
}

C++: #include <stdio.h>



int main (void)
{
int n;
scanf("%d", &n);
	while(n =! 0){
		int a[n];
		for (int i = 0; i<n; ++i) {
			scanf("%d", &a[i]);
		}
    for(int i=0;i<n-1;i++){

      // 下から上に順番に比較します
      for(int j=n-1;j>i;j--){

	// 上の方が大きいときは互いに入れ替えます
	if(a[j]<a[j-1]){
	  int t=a[j];
	  a[j]=a[j-1];
	  a[j-1]=t;
	}
      }
    }
	int sum = 0;
	for(int i=1; i=n-2; i++){
		sum = sum + a[i];
	}
	printf ("%d\n", sum);
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int prime[300000];
int main() {
	int n;
	while(cin >> n,n) {
		int ans = 0;
		vector<int> data;
		for(int i = 0; i < n; i++) {
			int t;
			cin >> t;
			data.push_back(t);
			ans += t;
		}
		sort(data.begin(), data.end());
		ans = ans - data[data.size()-1] - data[0];
		cout << ans / (n - 2) << endl;
	}
	return 0;
}

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

int main(){
	int n;

	while (cin >> n, n){
		int a[100];
		for (int i = 0; i < n; i++){
			cin >> a[i];
		}
		int sum = accumulate(a, a + n, 0);
		int Max = *max_element(a, a + n);
		int Min = *min_element(a, a + n);
		cout << (sum - (Max + Min)) / (n - 2) << endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	int n, s, j[1000], minj, maxj;
	
	while(cin >> n, n){
		s = 0;
		minj = maxj = 0;
		for(int i = 0; i < n; i++){
			cin >> j[i];
			s += j[i];
			if(i != 0) minj = min(minj, j[i]); else minj=j[0];
			if(i != 0) maxj = max(maxj, j[i]); else maxj=j[0];
		}
		s = (s - maxj - minj)/(n-2);
		cout << s << endl;
	}
	return 0;
}