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 <vector>
#include <algorithm>
using namespace std;
int main(){
	while(true){
		int score;
		int n;
		int maxs,mins;
		vector<int> s(n);
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>s[i];
		}
		maxs=*max_element(s.begin(),s.end());
		mins=*min_element(s.being(),s.end());
		for(int i=0;i<n;i++){
			score+=s[i];
		}
		cout<<(score-maxs-mins)/(n-2)<<endl;
	}
}

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

int main()
{
	int number;
	int score, sum, max, min;
	
	while(true)
	{
		cin >> number;
		if(!number) return 0;
		sum = 0, max = 0, min = 1000;
		for(int i = 0; i < number; ++i)
		{
			cin >> score;
			sum += score;
			if(score[i] > max) max = score;
			if(score[i] < min) min = score;
		}
		cout << (sum - max - min) / (number - 2) << endl;
	}
}

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

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

C++: #include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1e18 : 1e9;
const int MOD = 1000000007;
const long double EPS = 1e-8;


int main() {
	int n;
	while(cin >> n, n) {
		int macs = -1, mini = INF, sum = 0, s;
		rep (i, n) {
			cin >> s;
			macs = max(macs, s);
			mini = min(mini, s);
			sum += s;
		}
		cout << (sum - macs - mini) / (n - 2) << endl;
	}
	return 0;
}

C++: #include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef long long  ll;

/** Problem1147 : ICPC Score Totalizer Software **/
int main()
{
	int N;
	vector<int> s;
	
	while (cin>>N, N) {
		int sum=0;
		s.clear();
		rep(i, N) {
			int n;
			cin >> n;
			s.push_back(n);
			sum+=n;
		}
		
		int m = *min_element(s.begin(), s.end());
		int M = *max_element(s.begin(), s.end());
		
		sum -= m; sum -= M;
		
		cout << sum/(N-2) << endl;
		
	}
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RFOR(i, a, b) for (int i=a;i>=b;--i)
#define ll long long
#define all(a) a.begin(),a.end()
#define ull unsigned long long
#define pb(x) push_back(x)
#define dbg(x) cout<<#x<<" : "<<(x)<<endl;
using namespace std;
const int INF = 1500000000;
const double PI = 3.14159265359;
const int mod = 1000000000 + 7;

int n, s[1000];

void solve() {
  int res = 0, mins = 1000, maxs = 0;
  rep(i, n) {
    res += s[i];
    maxs = max(maxs, s[i]);
    mins = min(mins, s[i]);
  }
  res -= maxs;
  res -= mins;
  printf("%d\n", res / (n-2));
}

int main() {
  while(true) {
    scanf("%d", &n);
    if (!n) break;
    rep(i, n) scanf("%d", &s[i]);
    solve();
  }
  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[101];
int main(){
        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<<endl;
}

C++: #include <bits/stdc++.h>
using namespace std;
const int IINF = INT_MAX;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n;
    while(cin >> n, n){
        int sum=0,ma=0,mi=IINF;
        REP(i,n){
            int a;
            cin >> a;
            sum+=a;
            ma = max(ma, a);
            mi = min(mi, a);
        }
        cout << (sum-ma-mi)/(n-2) << endl;
    }
    return 0;
}

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

int N, S;
void solve(){
    while (cin >> N && N > 0){
        int sum = 0;
        int min = 1000000;
        int max = -1;
        for (int i = 0; i < N; i++){
            cin >> S;
            sum += S;
            if (min > S) min = S;
            if (max < S) max = S;
        }
        cout << (sum - max - min)/(N-2) << endl;
    }
}



int main(){
    solve();
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,s,m,M,ans;
	cin>>n;
	m = 1005;
	M= -1;
	ans=0;
	for(int i=0;i<n;i++){
		cin>>s;
		m=min(m,s);
		M=max(M,s);
		ans+=s;
	}
	n-=2;
	ans=ans-M-m;
	ans /= n;
	cout<<ans<<endl;

}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(x) x.begin(),x.end()


void solve(){
    int N;cin>>N;
    if(N==0)exit(0);
    vector<int>A(N);
    REP(i,N)cin>>A[i];
    sort(ALL(A));
    int sum = 0;
    FOR(i,1,N-1)sum+=A[i];
    cout<<sum/(N-2)<<endl;
}
signed main(){
    while(true){
        solve();
    }
}

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

int main()
{
	int in,a,maxer=0,miner=1000;
	int sum=0;
	int i=0;
	double ave=0.0;
	while( scanf("%d",&in) !=0 ){
		for(i=0; i<in; i++){
			cin >> a;
			maxer=max(a,maxer);
			miner=min(a,miner);
			sum += a;
		}
		sum = sum - maxer - miner;
		ave = sum/(in-2);
		cout << floor(ave) << endl;
		sum = maxer = ave = 0;
		miner=1000;
	}
}

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

int main(){
	int n;
	int s[100];
	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;
}