Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

int main()
{
  vector<int> vec;

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

    int least = 1001;
    int most = 0;
    int sum = 0;

    rep(i, n)
    {
      int x;
      cin >> x;
      least = min(least, x);
      most = max(most, x);
      sum += x;
    }

    int ave = (sum - least - most) / (n - 2);
    vec.push_back(ave);
  }

  for (auto &&i : vec)
  {
    printf("%d\n", i);
  }
}

C++: #include<iostream>
using namespace std;
 
int main(){
    int n,i;

    while(1){
        int point[100]={0,};
        int min = 1000;
        int max = 0;
		long total = 0;
        cin >> n;
        if(!n) break;
        for(i=0;i<n;i++){
            cin >> point[i];
            if(point[i] > max) max = point[i];
            if(point[i] < min) min = point[i];
			total += point[i];
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

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

int main() {
  int n;
  while (cin >> n && n) {
    int s[110];
    for (auto i=0; i<n; i++) {
      cin >> s[i];
    }
    int max = 0;
    int min = 1010;
    int sum = 0;
    for (auto i=0; i<n; i++) {
      sum += s[i];
      if (max < s[i]) max = s[i];
      if (min > s[i]) min = s[i];
    }
    cout << (sum - max - min)/(n-2) << endl;
  }
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define INF 1e09

using namespace std;

int main(){
  int n;
  int total, maxim, minim;
  int tmp;
  while(cin >> n){
    total = 0; maxim = -INF; minim = INF;
    REP(i, n) { cin >> tmp; total += tmp; maxim = max(maxim, tmp); minim = min(minim, tmp); }
    total -= (maxim + minim);
    cout << total / (n - 2) << endl;
  }
  return 0;
}

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

//vector??????????§£???
int main(){
	while (1){
		int n;
		cin >> n;
		//???????????¶
		if (n == 0) break;
		//??\???
		vector<int> num;
		for (int i = 0; i < n; i++){
			int tmp;
			cin >> tmp;
			num.push_back(tmp);
		}
		//????¨????????°????????????§???????¨????
		int max = -1;
		int min = 99999;
		int sum = 0;
		for (int i = 0; i < num.size(); i++){
			if (num[i] >= max) max = num[i];
			if (num[i] <= min) min = num[i];
			sum += num[i];
		}
		//??????????¨????
		int avg = floor((sum - max - min) / (n - 2));
		cout << avg << endl;
	}
	return 0;
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

using namespace std;

int solve(int n) {
	int ma = 0, mi = 1e9;
	int sum = 0;
	rep(i, n) {
		int x; cin >> x;
		chmax(ma, x);
		chmin(mi, x);
		sum += x;
	}
	return (sum - ma - mi) / (n - 2);
}

signed main() {
	int n;
	while (cin >> n, n) cout << solve(n) << endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
vector <string> v;
vector<int> ans;
string s ;
int main(){
  int N;
  cin >>N;
  while(N != 0){
    vector<int> num;
    for (int j = 0;j < N;j++){
      int x;
      cin >> x;
      num.push_back(x);
    }
    sort(num.begin(),num.end());
    int z;
    z = accumulate(num.begin()+1,num.end()-1,0);
    z = (int)z/(N-2);
    ans.push_back(z);
    cin >> N;
}

for (int i = 0 ; i < (int)ans.size();i++){
  cout <<ans[i]<<endl;
}

  return 0;
}