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(){
    ios::sync_with_stdio(false);
    while(1){
        vector<int> point;
        int n,x;
        long long sum=0;
        cin >> n;
        if(n==0)    break;
        while(n--){
            cin >> x;
            point.push_back(x);
        }
        sort(point.begin(),point.end());
        for(int i=1;i<point.size()-1;i++){
            sum+=point[i];
        }
        cout << sum/(point.size()-2) << "\n";
        point.clear();
    }
}

C++: #include <iostream>
using namespace std;
int main(){

	while (1){
		int n;
		int sum = 0;
		cin >> n;
		if (n == 0){
			return 0;
		}
		int s;
		int max = -1;
		int min = 9999;
		for (int i = 0; i < n; i++){
			cin >> s;
			sum += s;
			if (s > max){
				max = s;
			}else if (s < min){
				min = s;
			}
		}
		int ans = (sum - max - min) / (n - 2);
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
  int n;
  while (cin >> n, n){
    int ma=0, mi=INT_MAX;
    int sum = 0;
    for (int i = 0; i < n; i++){
      int x; cin >> x;
      sum += x;
      ma = max(ma, x); mi = min(mi, x);
    }
    cout << (sum - mi - ma) / (n - 2) << endl;
  }
}

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

using namespace std;
typedef long long ll;

void solve(vector<int> &A) {
    sort(A.begin(), A.end());
    int N = A.size();
    ll sum = 0;
    for(int i = 1; i < N - 1; i++) {
        sum += A[i];
    }
    cout << sum / (N - 2) << endl;
}

int main() {
    int N;
    while(cin >> N, N) {
        vector<int> A(N);
        for(int i = 0; i < N; i++) cin >> A[i];
        solve(A);
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) return 0;
        
        vector<int> A(N);
        for(int i=0;i<N;i++) cin>>A[i];
        sort(all(A));
        
        ll sum=0;
        
        for(int i=1;i<N-1;i++) sum+=A[i];
        cout<<sum/(N-2)<<endl;
    }
}

C++: #include <cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int maxi=0,mini=1000,sum=0;
		rep(i,n){
			int a; scanf("%d",&a);
			sum+=a;
			if(maxi<a) maxi=a;
			if(mini>a) mini=a;
		}
		printf("%d\n",(sum-maxi-mini)/(n-2));
	}

	return 0;
}

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

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

	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define endl '\n'
const int INF = (1 << 30);
using namespace std;
typedef long long int ll;

bool solve(){
    int n, smax=0, smin=INF, sum=0, s;
    cin >> n;
    if(!n) return false;
    REP(i,n){
        cin >> s;
        smax = max(s, smax);
        smin = min(s, smin);
        sum += s;
    }
    cout << (sum - smin - smax) / (n-2) << endl;
    return true;
}

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

    while(solve());
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int in;
    int num;
    int ans=0;
    int point[105]={};
    while(1==1)
    {
        
        scanf("%d\n",&in);
        if(in==0)return 0;
        num=in;
        ans=0;
        REP(i,num)
        {
            scanf("%d\n",&point[i]);
            ans+=point[i];
        }
        sort(point[0],point[num]);
        ans-=(point[0]+point[num-1]);
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int main(){

	while (1){
		int n;
		int sum = 0;
		cin >> n;

		if (n == 0){
			return 0;
		}

		int s;
		int max = -1;
		int min = 9999;
		for (int i = 0; i < n; i++){
			cin >> s;
			sum += s;
			if (s >= max){
				max = s;
			}
			if (s <= min){
				min = s;
			}
		}
		int ans = floor((sum - max - min) / (n - 2));
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main(void){
int n;
while(1){
	cin>>n;
	if(n==0)break;
	int b;
	priority_queue<int> a;
	for(int i=0;i<n;i++){
		cin>>b;
		a.push(b);
	}
	a.pop();
	int ans=0,c;
	while(a.size()!=1){
ans+=a.top();
a.pop();
	}
	ans/=n-2;
	cout<<ans<<endl;
}
	return 0;
}

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

int main()
{
  int n, a[101];
  while (cin >> n, n){
    int res = 0;
    for (int i = 0; i < n; i++){
      cin >> a[i];
      res += a[i];
    }
    sort(a, a + n);
    res -= (a[0] + a[n - 1]);
    cout << (int)floor(res / (n - 2)) << endl;
  }
}

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

int main() {
    vector<int> avg;
    while(true) {
        int n;
        cin >> n;
        if(n==0)
            break;

        vector<int> v(n);
        int sum = 0;
        int ma = -1;
        int mi = 10000;
        for(int i=0;i<n;i++) {
            int vi;
            cin >> vi;
            ma = max(ma, vi);
            mi = min(mi, vi);
            sum += vi;
        }

        sum = sum - ma - mi;
        avg.push_back(sum/(n-2));
    }
    for(int i=0;i<avg.size();i++)
        cout << avg[i] << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		ll n;
		cin>>n;
		if(n==0) break;
		vector<ll> s(n);
		REP(i,n) cin>>s[i];
		sort(ALL(s));
		ll sum=accumulate(ALL(s),0);
		sum-=s[0]+s[n-1];
		cout<<sum<<endl;
	}
}

C++: #include <iostream>
using namespace std;
 
int main() {
	int n;
	while(1){
	cin >> n;
	if(n==0)break;
	int min,max;
	int s,x;
	cin >>s;
	min=s;
	max=s;
	x=s;
		for(int i=0;i<n-1;i++){
		cin >>s;
		x=x+s;
		if(min >s) min=s;
		if(max <s) max=s;
 
		}
	x=x-max-min;
    x=x/(n-2);
	cout << x <<endl;
	}
	return 0;
}