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())
		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 < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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;
int a[10000];
int main(){
        while(1) {
                cin>>n;
                if(n==0) {
                        return 0;
                }
                for(int i=0; i<n; i++) {
                        cin>>a[i];
                }
                int sum=0;
                sort(a,n);
                for(int i=1; i<n-1; i++) {
                        sum+=a[i];
                }
                cout<<sum/(n-2)<<endl;
                n=0;
        }
}

C++: #include <iostream>
#define INF (2<<29)
using namespace std;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    for(;;){
        int a,n,s=0,max=0,min=INF;
        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++: #include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

int main(){
  int n;
  int data[105];
  
  while(true){
    cin>>n;
    if(n==0)break;

    rep(i,0,n)cin>>data[i];
    sort(data,data+n);

    long long sum=0;
    rep(i,1,n-1)sum+=data[i];

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

C++: #include<iostream>
using namespace std;
int add(int, int);

int main() {
	int x, y, s, max, a;

	while (true) {
		int max = 0;
		cin >> x >> y >> s;

		if (x == 0 && y == 0 && s == 0)	break;

		for (int i = 1; i < s; i++) {
			for (int j = 1; j < s; j++) {
				if ((add(i, x) + add(j, x)) == s) {
					a = (add(i, y) + add(j, y));
					if (a > max)	max = a;
				}
			}
		}
		cout << max << endl;
	}

	return 0;
}

int add(int a, int t) {
	return a*(100 + t)/100;
}

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

using namespace std;

int main()
{
	int N;
	while(true){
		cin >> N;
		if(N==0){return 0;}

		int* x = new int[N];
		int sum=0;

		for(int i=0; i<N; i++){
			cin >> x[i];
			sum += x[i]; 
		}
		int* x_max = max_element(x,x+N);
		int* x_min = min_element(x,x+N);

		cout << (sum - *x_max - *x_min)/(N-2) << endl;

		delete[] x;
	}
}

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

using namespace std;

int main(){
	int n;
	while(cin >> n){
		if(n == 0) break;
		int m[n];
		for(int i = 0;i < n;i++) cin >> m[i];
		sort(m,m+n);
		cout << accumulate(m+1,m+n-1,0) / (n - 2) << endl;
	}
}

C++: #include<iostream>

using namespace std;

int n;
int score[100];
int bucket[1001] = {0};
int sum_score, ave_score;

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

void sort(){
    for(int i = 0; i < n; i++){
        bucket[score[i]]++;
    }

    for(int i=0,k=0; i < 1001;i++){
        for(int j=0; j<bucket[i]; j++){
            score[k++] = i;
        }
    }
}

void ave(){
    for(int i=1; i < n-1; i++){
        sum_score += score[i];
    }
    ave_score = sum_score/(n-2);
}

void reset(){
    sum_score = 0;
    for(int i=0;i<1001; i++){
        bucket[i] = 0;      
    }
}

int main(void){
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        set_score();
        sort();
        ave();
        cout << ave_score << endl;
        reset();
        
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
if(i != 0){
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    REP(_, 20) {
        int n; cin >> n;
        if (n == 0) break;
        vector<int> v;
        REP(i, n) {
            int x; cin >> x;
            v.push_back(x);
        }
        sort(v.begin(), v.end());
        int ans = 0;
        FOR(i, 1, n-1) ans += v[i];
        ans /= n - 2;
        cout << ans << endl;
    }
}

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

int main() {
	while(true){
		int number;			//?????£??????????????°
		cin >> number;
		if(number == 0){exit(0);}

		int score[number];
		int i;
		for(i=0;i<number;i++){	//???????????????
			cin >> score[i];
		}

		int max = 0;			//????????????
		int maxJ;				//?????????????????????????????£??????
		int min = 1001;
		int minJ;
		for(i=0;i<number;i++){	//??????????????¨????°??????????????????????
			if(max < score[i]){
				maxJ = i;
			}
			if(score[i] < min){
				minJ = i;
			}
		}

		int sum = 0;
		for(i=0;i<number;i++){
			if(i != maxJ && i != minJ){
				sum += score[i];
			}
		}
		cout << sum << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (n > 0) {
    int sum = 0;
    int mx = 0;
    int mn = 10000;
    int x;
    for (int i = 0; i < n; i++) {
      cin >> x;
      sum += x;
      if (x > mx) mx = x;
      if (x < mn) mn = x;
    }
    cout << (sum - mx - mn) / (n - 2) << endl;
    cin >> n;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	
	cin.tie( 0 );
	ios::sync_with_stdio( false );
    
	while(true){
        	int n;
        	cin >> n;
        
        	if(n == 0){ break; }
        	int MAX = INT_MIN ,MIN = INT_MAX;
        	vector<int> vc(n);
        
        	for(int i=0; i<n; i++){
            		cin >> vc[i];
            		MAX = max(MAX, vc[i]);
            		MIN = min(MIN, vc[i]);
        	}
        	auto res = (accumulate(vc.begin(), vc.end(), 0)) - (MAX + MIN);
        	cout << res / (n-2) << endl;
    	}
    	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
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, cmax = 10000, cmin = -1;
  int sum=0,a;
  while(cin >> n, n){
    REP(i,n){
      cin >> a ;
      cmax = max(cmax,a);
      cmin = min(cmin,a);
      sum += a;
    }
    cout << (sum-cmax-cmin)/(n-2) << endl;
  }
  return 0;
}