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<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()
using namespace std;
int S[1001] = {0};

int main() {
	int N;

	while(true) {
		cin >> N;

		if (N == 0) { break; }
		rep(i,N) {
			cin >> S[i];
		}
		sort(S,S+N);
		int ave = accumulate(S+1,S+N-1,0) / (N-2);
		cout << ave << endl;
	}
	

	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
    int n,s[1000], i;
    while (cin >> n && n>0){
        int sum = 0, maximum =0, minimum = 10000;
        for (i = 0; i < n; i++){
            cin >> s[i];
            sum += s[i];
        }
        for (i = 0; i < n; i++){
            maximum = max(maximum, s[i]);
            minimum = min(minimum, s[i]);
        }
        cout << (sum - maximum - minimum)/(n -2) << endl;
    }
}

C++: #include<stdio.h>
int main(){
  int n,a[100],i,max=0,min=1000,c;
  while(1){
    c=0;
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
      if(max<a[i])max=a[i];
      if(min>a[i])min=a[i];
    }
    for(i=0;i<n;i++){
      if(max==a[i])a[i]=0;
      if(min==a[i])a[i]=0;
      c+=a[i];
    }
    printf("%d\n",c/(n-2));
  }
  return 0;
}

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

using namespace std;

struct CONTEST_DATA{
	int judgements;
	vector< int > points;
};

int main( void ){

	vector< CONTEST_DATA > contests;
	vector< int > answers;

	while( true ){
		CONTEST_DATA cd;
		cin >> cd.judgements;
		if( cd.judgements == 0 ){
			break;
		}
		int point;
		for( int i = 0; i < cd.judgements; i++ ){
			cin >> point;
			cd.points.push_back( point );
		}
		contests.push_back( cd );
	}

	for( int i = 0; i < contests.size(); ++i ){
		sort( contests[ i ].points.begin(), contests[ i ].points.end() );
	}
	for( int i = 0; i < contests.size(); ++i ){
		auto p = contests[i].points.begin;
		contests[ i ].points.erase( p );
	}
	for( int i = 0; i < contests.size(); ++i ){
		sort( contests[ i ].points.begin(), contests[ i ].points.end(), greater<int>() );
	}
	for( int i = 0; i < contests.size(); ++i ){
		auto p = contests[i].points.begin;
		contests[ i ].points.erase( p );
	}

	for( int i = 0; i < contests.size(); ++i ){
		int answer;
		for( int l = 0; l < contests[ i ].points.size(); ++l ){
			answer += contests[ i ].points[ l ];
		}
		answer / contests[ i ].judgements;
		answers.push_back( answer );
	}

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

	return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define rep(i, n) for(int i = 0;i < n;i++)
#define reprb(i, n) for(int i = n;i >= 0;i--)
#define reps(i, m, n) for(int i = m;i < n;i++)
#define repsb(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
vector<int> a;
vector<int> b;

int main(int argc,char const *argv[]) {
	int n,s,mx=0,mi=0,total=0;
	while(true)
	{
		total=0,mx=0,mi=100000;
		cin>>n;

		if(n==0)	break;
		rep(i,n){
			cin>>s;
			total+=s;
			mx=max(s,mx);
			mi=min(s,mi);
		}
		total=total-mi-mx;
		total=total/(n-2);
		a.pb(total);
	}
	rep(i,a.size()){
		cout<<a[i]<<endl;
	}
	return 0;
}

C++: int main()
{
	//n: ??????????????°
	int n, point[100], sum = 0, ave = 0, max = 0, min = 0;
	while( cin >> n && n != 0){

		for(int i = 0; i < n; i++)
			cin >> point[i];

		sort(point, point + n);

		/*
		for(int i = 0; i < n; i++)
			cout << "Point: " << point[i] << " ";
		cout << endl;*/

		for(int i = 1; i < n-1; i++){
			sum += point[i];
		}
		ave = sum / (n-2);
		//cout << "Ave: ";
		cout << ave << endl;

		sum = 0;
		ave = 0;
		min = 0;
		max = 0;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
//---------------------------------------------------------------------------//
int n,sum=0;
int a[10000];
int main(){
        while(cin>>n) {
                for(int i=0; i<n; i++) {
                        cin>>a[i];
                }

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

C++: #include <iostream>

using namespace std;

int main()
{
  int n;
  int max, min, score;
  int s;
  
  while (1) {
    cin >> n;
    if (n == 0) break;

    max = 0;
    min = 1000;
    score = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      score += s;
      if (s > max) max = s;
      if (s < min) min = s;
    }
    cout << (score - max - min) / (n - 2) << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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;
    while(1) {
        cin >> n;
        if(n == 0) break;
        vector<int> point(n, 0);
        for(int i = 0; i < n; ++i) cin >> point[i];
        sort(point.begin(), point.end());
        int sum = 0;
        for(int i = 1; i < n-1; ++i) sum += point[i];
        cout << sum/(n-2) << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	while (true) {
		int n; cin >> n;
		if (n == 0) break;
		int score[100];
		rep(i, n) {
			cin >> score[i];
		}
		sort(score, score + n);
		int sum = 0;
		rep(i, n - 2) {
			sum += score[i + 1];
		}
		cout << sum / (n - 2) << endl;
	}

    return 0;
}