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 <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;
 
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;
            cout << max << ' ' << min << endl;
        }
        sum -= max + min;
        ans = sum / (n - 2);
        cout << ans << endl;
    }
    return 0;
}

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

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
        int n,sum=0,ans=0,max=0,min=1001;
        cin >> n;
        if(n==0) break;
        int s[n];
        for(int i=0; i<n; i++){
          cin >> s[i];
          sum += s[i];
        }
        for(int i=0; i<n; i++){
          if(s[i] > max) max = s[i];
          if(s[i] < min) min =s[i];
        }
        sum = sum -max -min;
        ans = sum/(n-2);
        cout << ans << endl;
  }
  return 0;
}

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


int main(){
	int num = 0;
	while (cin >> num){
		if (num == 0)return;
		vector<int> vec;
		int temp;
		while (cin >> temp){
			vec.push_back(temp);
		}
		sort(vec.begin(),vec.end());
		vec.pop_back();
		reverse(vec.begin(), vec.end());
		vec.pop_back();
		int ave = 0;
		for (int i = 0; i < vec.size(); i++)
			ave += vec[i];
		ave /= vec.size();
		cout << ave << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

int main(){
  while(1){
    cin >> n;
    if(!n)break;
    rep(i,0,n)cin >> d[i];
    sort(d,d+n);
    l = 0;
    rep(i,1,n-1)l += d[i];
    print(l / (n-2));
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;




int main(){
	int n;
	vi v;
	while(cin>>n){
		if(n==0)break;
		v.clear();
		rep(i,n){
			int a;
			cin>>a;
			v.pb(a);
		}
		sort(all(v));
		int sum=0;
		repc(i,1,n-1){
			sum+=v[i];
		}
		//cout<<sum<<" "<<n-2<<endl;
		cout<<(int)sum/(n-2)<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    while(cin>>n){
        if(n==0)return 0;
        vector<int> v(n,0);
        for(int &e:v){
            cin>>e;
        }
        sort(v.begin(),v.end());
        cout<<accumulate(v.begin()+1,v.end()-1,0)/(n-2)<<endl;
    }
    return 0;
}

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

const int MAX_N = 100;

int main() {
	int n,x;
	int score[MAX_N];

	while(cin >> n) {
		if(n == 0) return 0;

		int max = -1,max_i,min = 1001,min_i;
		for(int i = 0;i < n;i++) {
			cin >> x;
			score[i] = x;

			if(max < x) {
				max = x;
				max_i = i;
			}

			if(min > x) {
				min = x;
				min_i = i;
			}
		}

		//??¨??????????????°
		if(max_i == min_i) {
			cout << max << endl;
			continue;
		}

		int total = 0;
		for(int i = 0;i < n;i++) {
			if(i != max_i && i != min_i) total += score[i];
		}

		cout << total / (n - 2) << endl;
	}
}

C++: #include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
    int n;
    while (cin>>n,n) {
        vector<ll> a(n);
        rep(i,n) cin>>a[i];
        sort(a.begin(),a.end());
        a.pop_back();
        sort(a.begin(),a.end(),greater<>());
        a.pop_back();
        ll sum = 0;
        rep(i,n-2) sum+=a[i];
        ll ans=sum/(n-2);
        cout<<ans<<endl;
    }
}

C++: 
#include <iostream>

// using namespace std;

int main()
{
    while (true)
    {
        int x;
        std::cin >> x;
        if (x == 0)
        {
            break;
        }
        long sum = 0;
        long max = 0;
        long min = 1000;
        for (int i = 0; i < x; i++)
        {
            long j;
            std::cin >> j;
            max = std::max(max, j);
            min = std::min(min, j);
            sum += j;
        }
        sum -= (min + max);
        std::cout << sum / (x - 2) << std::endl;
    }
}

C++: #include <iostream>
#include <numeric>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

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

	while (1)
	{
		int num = 0; cin >> num;
		if (num == 0) { break; }
		vector<int> scr(num, 0);
		rep(i, num){ cin >> scr[i]; }
		int ans = 0;
		ans = accumulate(all(scr), 0) - *max_element(all(scr)) - *min_element(all(scr));
		printf("%d\n", ans / (num - 2));
	}

	return 0;
}

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

int n,s;

int main(){
	int i;
	while( cin >> n ){
		if( !n )break;
		
		int ans = 0,mx = 0,mn = 10000;
		for( i = 0; i < n; i++ ){
			cin >> s;
			ans += s;
			mx = max( mx, s );
			mn = min( mn, s );
		}
		ans -= mx+mn;
		cout << ans/(n-2) << endl;
	}
	return 0;
}