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<algorithm>
#include<climits>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl;

int main()
{
	int n;
	for (; cin >> n, n != 0;)
	{
		int Min = INF;
		int Max = -1;
		int sum = 0;
		REP(i, n)
		{
			int temp;
			cin >> temp;
			Min = min(Min, temp);
			Max = max(Max, temp);
			sum += temp;
		}
		sum =sum - Min - Max;
		int ans = sum / (n-2);
		cout <<ans<< endl;
	}
	return 0;
}

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

int main() {
	int n, a[100];
	while(1){
		cin >> n;
		if(n==0) break;
		int min, max, sum, avg;
		for(int i=0; i<n; i++)
			cin >> a[i];
			min = max = sum = a[0];
		for(int j=1; j<n; j++){
			sum += a[j];
			if(min>a[j]) min = a[j];
			if(max<a[j]) max = a[j];
		}
		avg = (sum-max-min)/(n-2);
		cout << avg << endl;
	}
	return 0;
}

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

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

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

        int max=0,min=1000;;

        for(int i=0;i<n;i++){
            if(s[i]>max)max=s[i];
            else if(s[i]<min)min=s[i];
        }
        
        int sum=0;
        for(int i=0;i<n;i++){
            sum +=s [i];
        }


        sum -=max;
        sum -=min;

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

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,m;
	int a,b,c;
	int i,j,k;
	int s=0;
	while(cin>>n){
		if(!n)break;
		b=0,c=1e5,s=0;
		for(i=0;i<n;i++){
			cin>>a;
			if(b<a)b=a;
			if(a<c)c=a;
			s+=a;
		}
		s-=b+c,n-=2;
		s/=n;
		cout<<s<<endl;
	}
}

C++: #include<iostream>
//#include<fstream>

using namespace std;

const int calc(int*, int);


int main(){
//	ifstream fin("in.txt");

	int data[20] = {};
	int count = 0;
	while (true){
		cin >> count;
		if (count == 0)break;
		for (int i = 0; i < count; i++){
			cin >> data[i];
		}

		for (int i = 1; i < count; i++){
			for (int j = i; j > 0; j--){
				if (data[j - 1] > data[j]){
					int tmp = data[j];
					data[j] = data[j - 1];
					data[j - 1] = tmp;
				}
			}
		}
		cout << calc(data, count) << endl;
	}

	return 0;
}

const int calc(int* a, int count){
	if (count <= 0)return 0;

	int ave = 0;

	for (int i = 1; i < count - 1; i++)ave += a[i];
	return ave / (count - 2);
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int n;
  while(scanf("%d",&n),n){
    vector<int> v(n);
    for(int i=0;i<n;i++){
      int tmp;
      scanf("%d",&tmp);
      v[i]=tmp;
    }
    double ans=0;
    sort(v.begin(),v.end());
    for(int i=1;i<v.size()-1;i++){
      ans+=(double)v[i];
    }
    printf("%d\n",(int)(ans/(v.size()-2)));
  }
  return 0;
}

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

int main(void)
{
    int sum, n, mmin, mmax, in;
    while(1) {
        sum = 0; mmax = -1; mmin = 114514810;
        cin >> n;
        if(n == 0) break;
        for(int i=0; i<n; i++) {
            cin >> in;
            sum += in;
            mmax = max(mmax, in);
            mmin = min(mmin, in);
        }
        sum = sum - mmax - mmin;
        cout << sum / n << endl;
    }
    
    return 0;
}

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

using namespace std;

int main(){
	double res;
	for(int n; cin >> n, n; cout << (int)res << endl){
		res = 0.0;
		vector<int> l;
		for(int i = 0; i < n; i++){
			int buf; cin >> buf;
			l.push_back(buf);	
		}
		sort(l.begin(), l.end());
		for(int i = 1; i < l.size() - 1; i++){res += (double)l[i];}
		res /= (double)(l.size() - 2);
	}
	return 0;
}

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

vector<int> v;


int main(){
  int n;
  while(cin>>n,n!=0){
    v.resize(0);
    for(int i=0;i<n;i++){
      int tmp;
      cin>>tmp;
      v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=1;i<v.size()-1;i++){
      ans+=v[i];
    }
    ans/=(n-2);
    cout<<ans<<endl;
  }
}

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

int main(){
    while (1){
	int n;
	vector<int> s;
	
	cin >> n;
	if (n == 0) break;
	int t;
	for (int i = 0; i < n; i++){
	    cin >> t;
	    s.push_back(t);
	}
	sort(s.begin(), s.end());

	int score = 0;
	for (int i = 1; i < s.size() - 1; i++){
	    score += s[i];
	}
	score /= s.size() - 2;

	cout << score << endl;
    }
}

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    for(;;){
        int a,n,s=0,max=0,min=INT_MAX;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            s+=a;
            if(max<a) max=a;
            if(min>a) min=a;
        }
        cout<<(s-max-min)/n<<endl;
    }
    return 0;
}

C++: // PKU 3325
#include<algorithm>
#include<cstdio>
#define rep( i, a ) for( int i = 0; i != (a); ++i )

int main()
{
	int n;
	while( scanf( "%d", &n ), n )
	{
		int ma = 0, mi = 1 << 30, sum = 0;
		rep( i, n )
		{
			int a;
			scanf( "%d", &a );

			sum += a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
		}

		printf( "%d\n", (sum - ma - mi) / (n - 2) );
	}

	return 0;
}

C++: int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int max = -1, min = 10000, sum = 0, score = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> score;
            sum += score;
            if(score > max) max = score;
            if(score < min) min = score;
        }
        sum -= max + min;
        ans = sum / (n - 2);
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <stdio.h>

using namespace std;

int cmax(int n, int s[200]){
	int max;
	for(int i = 0;i < n;i++){
		if(i == 0 || max < s[i]){
			max = s[i];
		}
	}
	return max;
}

int cmin(int n, int s[200]){
	int min;
	for(int i = 0;i < n;i++){
		if(i == 0 || min > s[i]){
			min = s[i];
		}
	}
	return min;
}

int main(){
	int n, sum, s[200];
	while(1){
		cin >> n;
		if(n == 0) break;
		
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> s[i];
		}
		int max = cmax(n, s);
		int min = cmin(n, s);

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

		sum = sum - max - min;
		int ans = sum / (n-2);

		cout << ans << endl;
	}

	return 0;
}