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 <stdio.h>

int main(void)	{
	
	int n, s, smax, smin, ssum, mean;
	
	while (true)	{
		
		scanf("%d", &n);
		
		if (n == 0)	{
			break;
		}
		
		smax = 0;
		smin = 1000;
		ssum = 0;
		
		for (int i = 1; i <= n; i++)	{
			
			scanf("%d", &s);
			
			if (smax < s)	{
				smax = s;
			}
			if (smin > s)	{
				smin = s;
			}
			
			ssum += s;
		}
		
		mean = (ssum - smax - smin) / (n - 2);
		
		printf("%d\n", mean);
	}
	
	return 0;
}

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

int main() {
	int n, data;
	while(1) {
		scanf("%d", &n);
		if (n == 0) break;
		int sum=0, max=0, min=1001;
		for (int i=0; i<n; i++) {
			scanf("%d", &data);
			sum+=data;
			if (max < data) max=data;
			if (data < min) min=data;
		}
		printf("%d\n", (sum-max-min)/(n-2));
	}
}

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

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

int main(){
  int n;
  while(true){
    cin>>n;
    if(n==0)break;
    int sum=0;
    vector<int> v;
    rep(i,n){
      int tmp;
      cin>>tmp;
      sum+=tmp;
      v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    cout<<(sum-v[0]-v[n-1])/(n-2)<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n;
    while (cin>>n,n) {
        vector<int> a(n);
        rep(i,n) cin>>a[i];
        sort(a.begin(), a.end());
        ll ans = 0;
        for (int i = 1; i < n-1; ++i) {
            ans += a[i];
        }
        cout << ans/(n-2) << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int max;
	int min;
	int y[20] = { 0 };

	n = 1;
		int j = 0;
		while (1){
			
			cin >> n;
			if (n == 0) break;
			max = 0;
			min = 1000;
			for (int i = 0; i < n; i++){
				int x[1000] = { 0 };
				cin >> x[i];

				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] = y[j]-max - min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[k]<< endl ;
	}
	return 0;
}

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

void score(int x){
    int n;
    int point[21];
    int ave = 0;

    n = x;
    for(int i=0;i<n;i++) cin >> point[i];
    sort(point,point+n);
    for(int i=1;i<n-1;i++){
        ave += point[i];
    }
    cout << ave / (n - 2) << endl;
}

int main(){
    int x;
    while(x != 0){
        cin >> x;
        score(x);
    }
    
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int a=10000,b=-1,sum=0;
		for(int i=0;i<n;i++){
			int s;
			cin>>s;
			sum+=s;
			a=min(a,s);
			b=max(b,s);
		}
		cout<<(sum-a-b)/(n-2)<<endl;
	}
}

C++: # include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

  while (cin >> n && n) {
    vector<int> scr(n);
    for (int i=0; i<n; i++) {
      cin >> scr[i];
    }

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

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

  return 0;
}