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>
using namespace std;
int main(){
	while(true){
		int n;
		cin >> n;
		if(n==0){
			break;
		}
		const int MAXN=100;
		int a[MAXN];

		for(int i=0; i<n; i++){
			cin >> a[i];
		}
		int max=a[0], min=a[0], kei=0;
		for(int i=0; i<n; i++){
			if(max < a[i]){
				max=a[i];
			}
			if(min > a[i]){
				min=a[i];
			}
			kei+=a[i];
		}
		int heikin;
		heikin=(kei-max-min)/(n-2);
		cout << heikin << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		int max = -1, min = 1001;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			int m;
			cin >> m;
			sum += m;
			if (max < m) {
				max = m;
			}
			if (m < min) {
				min = m;
			}
		}
		sum -= (max + min);
		sum /= n - 2;
		cout << sum << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	vector<int> array;
	vector<int> ans;
	int i,x,max,min,sum,n;
	max = 0;
	min = 1000;

	while(1){
	cin>>n;
	if(n==0){
		for(i=0;i<sizeof(ans);i++){
			cout<<ans[i]<< endl;
		}

		break;
	}
	array.clear();
	sum=0;

	for(i=0;i<n;i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<n;i++){
		sum += array[i];
	}
	sum = sum-max-min;
	ans.push_back(sum/(n-2));  //2ひいた分だけ割る数を減らす 
	}

}

C++: #include<iostream>
using namespace std;
int N,S;

int main() {
	while (cin >> N && N>0) { // By while (), adopt the form of std in 
		int sum = 0;
		int max = 0;
		int min = 0;
		for (int i=0; i<N; i++) {
			cin >> S;
			sum += S; // calculate sum
			if (max < S) max = S; // search max
			if (min > S) min = S; // search min
		}
		int ans;
		ans = (sum-max-min)/(N-2);
		cout << ans << endl;
	}
	return 0;
}

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

using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::sort;

void input(vector<int>& v, int number) {
    for (int i = 0; i < number; i ++) { 
        int value;
        cin >> value;
        v.push_back(value);
    }   
    sort(v.begin(), v.end());
}

void calc(vector<int> v) {
    int total = 0;
    int average;
    int size = v.size();
    for (int i = 1; i < size - 1; i ++) {
        total += v[i];
    }   
    average = total / (size - 2); 
    cout << average << endl;
}

int main(void) {
    int number;
    cin >> number;
    while (number != 0) {
        vector<int> v(0);
        input(v, number);
        calc(v);
        cin >> number;
    }   
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>



using namespace std;



int main()
{
	int n, s, sum;
	
	while (cin >> n)
	{
		if (n == 0) break;
		
		vector<int> vi;
		for (int i=0; i<n; i++)
		{
			cin >> s;
			vi.push_back(s);
		}
		
		sort(vi.begin(), vi.end());
		
		/*
		//テスト出力
		for (int i=0; i<vi.size(); i++)
		{
			cout << vi[i] << endl;
		}
		*/
		
		sum = 0;
		for (int i=1; i<vi.size()-1; i++)
		{
			sum += vi[i];
		}
		
		cout << sum / (vi.size() - 2) << endl;
	}
	
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  while(true) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> v;
    int a;
    rep(i, n) {
      cin >> a;
      v.push_back(a);
    }
    sort(ALL(v));

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

}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int n, cmax = 10000, cmin = -1;
  int sum=0;
  while(cin >> n, n){
    REP(i,n){
      cin >> a ;
      cmax = (cmax,a);
      cmin = (cmin,a);
      sum += a;
    }
    cout << (sum-cmax-cmin)/(n-2) << endl;
  }
  return 0;
}