Go: /*
	Problem A: ICPC 得点集計ソフトウェア
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// 標準入力を取得するScannerのインスタンスを作成
var sc = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込み文字列として返す
func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func average() (avg int) {
	// 審判の人数を取得する
	n, _ := strconv.Atoi(readLine())

	// 得点
	score := make([]int, 0, n)

	// 得点を読み込む
	for n > 0 {
		line, _ := strconv.Atoi(readLine())
		score = append(score, line)
		n--
	}

	if len(score) == 0 {
		return 0
	}

	// ソート
	sort.Ints(score)
	// 先頭を削除
	score = append(score[:0], score[1:]...)
	// 末尾を削除
	score = score[:len(score)-1]

	// 合計
	for i := 0; i < len(score); i++ {
		avg += score[i]
	}

	// 平均
	avg = avg / len(score)
	return avg
}

func main() {
	// 改行区切りから単語(スペース)区切りで読み込むように変更する
	sc.Split(bufio.ScanWords)
	for {
		avg := average()
		if avg != 0 {
			fmt.Println(avg)
		} else {
			break
		}
	}
}

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;
}

C++: #define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int A[101];

int main()
{
	int n; 
	while(1) {
		cin >> n;
		if (!n) break;
		int minx = inf, maxx = 0, sum = 0;
		rep(i,0,n) {
			int t;
			cin >> t;
			minx = min(minx, t);
			maxx = max(maxx, t);
			sum += t;
		}
		sum -= minx + maxx;
		int ans = floor((double)sum / (n-2));
		cout << ans << endl;
	}

 	return 0;
}