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 main(){
	int n;
	int x[1000] = { 0 };
	int y[20] = { 0 };
	int max;
	int min;
	n = 1;
		int j = 0;
		while (n != 0){
			
			cin >> n;
			max = 0;
			min = 1000;
				y[j] = 0;
			for (int i = 0; i < n; i++){
				cin >> x[i];
				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] -= max + min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[j]<< endl ;
	}
	return 0;
}

C++: # include <iostream>
# include <vector>
# include <string>
using namespace std;
int main() {
	int n, a;
	while (cin >> n&&n != 0) {
		int sum = 0, min = 10000, max = 0;
		for (int i = 0; i < n; i++) {
			cin >> a;
			if (a < min) {
				min = a;
			}
			if (max < a) {
				max = a;
			}
			sum += a;
		}
		sum = sum - max - min;
		cout << sum / (n - 2) << endl;
	}
}

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

int main(){
    int n;
    while(cin>>n,n){
        int mx=0,mn=1001,s;
        int sum=0;
        rep(i,n){
            cin>>s;
            sum+=s;
            mx=max(mx,s),mn=min(mn,s);
        }
        cout<<(sum-mx-mn)/(n-2)<<endl;
    }
    return 0;
}

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

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define prime first
#define weight second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		map<int, int> ev;
		int max = -1, min = 1001;
		
		rep(i, n){
			int s = 0;
			cin >> s;

			if(s > max) max = s;
			else if(s < min) min = s;

			if(ev.find(s) != ev.end()) ev[s]++;
			else ev[s] = 1;
		}

		ev[max]--;
		ev[min]--;

		double result = 0.0, factor = 0.0;
		
		for(map<int, int>::iterator it = ev.begin(); it != ev.end(); it++){
			rep(i, it->second){
				result += it->first;
				factor++;
			}
		}

		cout << (int)result / (int)factor << endl;
	}
	

	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>

typedef long long          ll;
typedef unsigned int       uint;
typedef unsigned long long ull;

using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    sort(s.begin(), s.end());
    std::cout << accumulate(s.begin() + 1, s.end() - 1, 0) / (s.size() - 2) << std::endl;
  }
}

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

int main(){
	int n, sum, x;
	while(cin >> n, n){
		vector<int> vec;
		for(int i = 0; i < n; i++){
			cin >> x;
			vec.push_back(x);
		}
		sort(vec.begin(), vec.end());

		sum = 0;
		for(vector<int>::iterator it = vec.begin() + 1; it != vec.end() - 1; it++){
			sum += *it;
		}
		cout << sum / (vec.size() - 2) << endl;
	}
}

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

using namespace std;

int main() {
  int n, input;

  while (true) {
    cin >> n;
    if (n == 0) { break; }

    vector<int> scores;
    for (int i = 0; i < n; i++) {
      cin >> input;
      scores.push_back(input);
    }

    cout << (accumulate(scores.begin(), scores.end(), 0) - *max_element(scores.begin(), scores.end()) - *min_element(scores.begin(), scores.end())) / (n - 2) << endl;
  }

  return 0;
}

C++: aaa

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

int s[100];

int main(){
	int n;
	while(scanf("%d", &n),n){
		for(int i = 0; i < n; i++) scanf("%d", &s[i]);
		sort(s,s+n);
		int sum = 0;
		for(int i = 1; i < n-1; i++){
			sum += s[i];
		}
		printf("%d\n", sum/(n-2));
	}
}

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

int main()
{
	int N, n, sum, largest, smallest;
	sum  = 0; largest = 0; smallest = 1000;
	
	cin >> N;
	
	for(int i = 0; i<N; i++)
	{
		cin >> n;
		sum += n;
		
		if(smallest > n){ smallest = n;}
		if(largest < n){ largest = n;}
	}
	
	cout << (sum-smallest-largest)/(N-2) << endl;
}