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 <stdio.h>
#include <climits>
#include <iostream>
using namespace std;
int main(){
  int n,work;
  while(1){
    int sum = 0,max=0,min=INT_MAX;
    cin >> n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin >> work;
      max = (max < work) ? work : max;
      min = (min > work) ? work : min;
      sum+=work;
    }
    sum -=max;
    sum -=min;
    printf("%d\n",sum/(n-2));
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int n,score[111],ave;

void solve(){
  ave = 0;
  cin>>n;

  if(n == 0) exit(0);

  REP(i,n){
    cin>>score[i];
  }

  sort(score,score+n);

  FOR(i,1,n-1){
    ave += score[i];
  }
  ave /= (n-2);

  cout<<ave<<endl;
}


int main(){

  while(1){
    solve();
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) v.begin(), v.end()
template<class T> using V = vector<T>;

int main(){
  int n;
  while(cin>>n,n){
    V<int> a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    int ans = accumulate(a.begin()+1,a.end()-1,0);
    cout << ans/(n-2) << endl;
  }
}

C++: #include "bits/stdc++.h"
using namespace std;
int main() {
	int n;
	while (cin >> n,n) {
		int Sum = 0;
		int Max = -1;
		int Min = 1001;
		for (int i = 0; i < n; i++) {
			int a; cin >> a;
			Sum += a; Max = max(Max, a); Min = min(Min, a);
		}
		Sum -= Max + Min;
		cout << Sum / (n - 2) << endl;
	}
}

C++: #include <iostream>
#include <utility>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

const int INF = 1 << 28;

int main()
{
  int n;
  while(cin >> n, n) {
    int ax = 0;
    int in = INF;
    int sum = 0;
    rep(i, n) {
      int m;
      cin >> m;
      ax = max(ax, m);
      in = min(in, m);
      sum += m;
    }
    sum -= ax;
    sum -= in;
    sum /= n - 2;

    cout << sum << endl;
  }
  return 0;
}

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

int main()
{
    int n,s;
    int sum = 0;
    std::vector<int> v;
    cin >> n;

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

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

    for(int i = 1; i < v.size() -1 ; i++)
    {
        sum += v[i];
    }
    int ave = sum / (v.size() - 2);
    cout << ave <<endl;
    return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	while (1) {
		int n;
		int s[101];
		int mini = INF;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			else if (mini > s[i]) {
				mini = s[i];
			}
			else {
				total += s[i];
			}
		}
		cout << total / (n - 2) << endl;
	}


}

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

#define ll long long int
#define ld long long double
#define reps(i,f,n) for(int i=f;i<n;i++)
#define rep(i,n) reps(i,0,n)
#define m1 cout<<"move1"<<endl
#define m2 cout<<"move2"<<endl
#define m3 cout<<"move3"<<endl
#define m4 cout<<"move4"<<endl

int main(){
  ll sum=0;
  int N=0;
  int max_v= -1;
  int min_v= 10000;
  int a;
  int b;
  // m2;
  while(cin>>a){
    N = a;
    // cout<<a<<endl;
    // m1;
    for(int i=0;i<N;i++){
      cin>>b;
      max_v=max(max_v,b);
      min_v=min(min_v,b);
      sum += b;
      // cout<<sum<<endl;
       }
    sum = sum - max_v - min_v;
    cout<<sum / ( N -2)<<endl;
    max_v=-1;
    min_v=1000;
    sum =0;
  }
  return 0;

}

C++: #include <iostream>
using namespace std;
int N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
 Max=0;
 Min=1000;
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<N; ++j){
	if(A[j]>Max) Max=A[j];
    }
  for (int k=0; k<N; ++k){
	if(A[k]<Min) Min=A[k];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
  Sum=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-1; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		i=maxnum;
		}
		if(score[i] < minscore){
		minscore = score[i];
		i = minnum;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<judge-1;j++){
lastscore += score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

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

using namespace std;

int main(){
	while(true){
		int n; cin >> n;
		if(n==0)break;

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

C++: #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  cin>>N;
  while(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 <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define prime first
#define weight second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		map<int, int> ev;
		int max = -1, min = 1001;
		rep(i, n){
			int s = 0;
			cin >> s;

			if(s > max) max = s;
			else if(s < min) min = s;

			if(ev.find(s) != ev.end()) ev[s]++;
			else ev[s] = 1;
		}

		ev[max]--;
		ev[min]--;

		int result = 0, factor = 0;
		for(map<int, int>::iterator it = ev.begin(); it != ev.end(); it++){
			for(int i = 0; i < it->second; i++){
				result += it->first;
				factor++;
			}
		}

		cout << result / factor << endl;
	}
	

	return 0;
}

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

int main(){
    int N, arr[100];
    while(scanf("%d", &N) != EOF && N != 0){
        for(int i = 0; i < N; i++){
            scanf("%d", arr+i);
        }
        sort(arr, arr + N);
        int s = 0;
        for(int i = 1; i < N-1; i++){
            s += arr[i]; 
        }
        printf("%d\n", s / (N-2));
    }
    return 0; 
}