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 <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;
}

C++: #include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>

using namespace std;

int main(void) {
	int dataset_num = 0;
	int sum = 0;
	int max = 0;
	int min = 1001;
	int score;
	int j_num;

	cin >> j_num;

	while (j_num != 0 && dataset_num < 20){
		for (int i = 0; i < j_num; i++){
			cin >> score;

			if (score > max) {
				max = score;
			}
			if (score < min) {
				min = score;
			}

			sum += score;
		}

		sum = sum - max - min;
		double ave_score = sum / (j_num-2);
		cout << ave_score << endl;

		cin >> j_num;
		dataset_num++;
		sum = 0;
		max = 0;
		min = 1001;
	}	
	return 0;
}

C++: /*** ICPC??????????¨???????????????§??¢ ***/

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

int main(){
	int n;
	int s[20];
	int sum;
	
	cin >> n;
	while(n > 2){
		for(int i=0; i<n; ++i){
			cin >> s[i];
		}
		
		sort(s, s+n);
		
		sum=0;
		for(int i=1; i<(n-1); ++i){
			sum+=s[i];
		}
		
		cout << sum/(n-2) << endl;
		cin >> n;
	}
	
	return 0;
}