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;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

int judge(int n){
  int max=-1, min=1001, sum=0;
  vi s(n);
  rep(i, n){
    cin >> s[i];
    sum+=s[i];
    if(s[i]>max)max=s[i];
    if(s[i]<min)min=s[i];
  }
  return (sum-max-min)/(n-2);
}

int main(){
  int cnt=0;
  vi ans(20);
  rep(i, 20){
    int n;
    cin >> n;
    if(n==0)break;
    ans[i]=judge(n);
    cnt++;
  }

  rep(i, cnt){
    if(ans[i]==-1)break;
    cout << ans[i] << endl;
  }

  return 0;
}

C++: #include <iostream>
#include<algorithm>
using namespase std;
int main(){
int n;
cin>>n;
int sum =0;
int ma =0;
int mi =100000;
int cnt =0;
for(int i=0;i<n;i++){int s;cin>>s;sum+=s;ma =max(ma,s);mi=min(mi,s);cnt++;}
cout<<(sum-mi-ma)/(cnt-2)<<endl
}

C++: #include<stdio.h>

int main(){
  int i, n, s;

  while (1) {
    scanf("%d", &n);
    if (n==0) {
      break;
    }
    int ans = 0, maxv = 0, minv = 1000;
    int score[n];
    for (i = 0; i < n; i++) {
      scanf("%d", &s);
      if (s > maxv) {
        maxv = s;
      }
      if (s < minv) {
        minv = s;
      }
      score[i] = s;
    }

    for (i = 0; i < n; i++) {
      ans += score[i];
    }

    printf("%d\n", (ans-maxv-minv)/(n-2));
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main{
  int a[2020];
  int i = 0;
  while (cin >> x){
    a[i++] = x;
  }
  saiten(a,0);
}
int saiten(a,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 N, S;
int main(){
  while(cin >> N && N>0){
    int sum = 0;
    int min = 1001;
    int max = -1;
    for(int i=0;i<N;++i){
      cin >> S;
      sum += S;
      if(min>S) min = S;
      if(max<S) max = S;
    }
    int ans = (sum-max-min)/(N-2);
    cout << ans << endl;
  }
}

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

int main() {
	int a,b,c;
	vector<int> d;
	while(1){
		d.clear();
		c = 0;
		cin >> a;
		if(a == 0)break;
		for(int i = 0;i < a;i++){
			cin >> b;
			d.push_back(b);
		}
		sort(d.begin(),d.end());
		for(int i = 1;i < d.size()-1;i++){
			c+=d[i];
		}
		cout << c/(d.size() - 2) <<endl;
	}	
	return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n;

	while(cin >> n, n) {
		vi score(n);
		int min=1000000, max=0, sum=0;

		REP(i, n) {
			cin >> score[i];
			if(score[i] < min) {
				min = score[i];
			}
			if(score[i] > max) {
				max = score[i];
			}
			sum += score[i];
		}

		cout << (sum-max-min)/(n-2) << endl;
	}
}

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

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

}

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

int main() {
	int n;//3<=n<=100
	int s;//0<=s<=1000
	int max,min,total,result;
	int i,finish=0;
	
	scanf("%d",&n);
	
	while(finish==0){
	max=0;
	min=1000;
	total=0;
	for(i=0;i<n;i++){
		scanf("%d",&s);
		if(s<min){min=s;}
		if(s>max){max=s;}
		total+=s;
	}
	result=(total-min-max)/(n-2);
	printf("%d\n",result);
	
	scanf("%d",&n);
	if(n==0){finish=1;}
	}
	return 0;
}

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

int main(void){
	int n,m,max,min,answer;
	while(1){
		cin >> n;
		max = 0;
		min = INT_MAX;
		answer = 0;
		if (!n) break;
		for (int i=0;i< n;i++){
			cin >> m;
			if (m > max) max = m;
			if (m < min) min = m;
			answer += m;

		}
		cout << (answer-max-min)/(n-2) << endl;

	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  while(true){
    int n;
    scanf("%d",&n);
    if(n==0)break;
    vi a(n);
    REP(i,n)scanf("%d",&a[i]);
    sort(ALL(a));
    int sum = 0;
    FOR(i,1,n-1)sum += a[i];
    sum /= (n-2);
    printf("%d\n",sum);
  }
  return 0;
}

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

int main() {

  long N;
  std::vector<long> v;
  long temp;
  long ans;
  long total;

  for(;;) {
    v.clear();
    std::cin >> N;
    if( N == 0 ) break;

    for(int i = 0; i < N; ++i) {
      std::cin >> temp;
      v.push_back(temp);
    }

    std::sort(std::begin(v), std::end(v));

    total = 0;
    for(int i = 1; i < N-1; ++i) total += v[i];
    ans = total / (N-2);

    std::cout << ans << std::endl;
  }
  
  return 0;
}

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

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

    vector<int> p(n);
    int nmax = -1, nmin = 1001;
    int imax, imin;
    for(int i=0; i<n; i++){
      cin >> p[i];
      if(p[i] > nmax){
	nmax = p[i];
	imax = i;
      }
      if(p[i] < nmin){
	nmin = p[i];
	imin = i;
      }
    }

    int ave = 0;
    for(int i=0; i<n; i++){
      if(i != imax && i != imin)
	ave += p[i];
    }
    ave /= n-2;

    cout << ave << endl;
  }
  
  return 0;
}