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>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n,s;
    while (1) {
        cin >> n;
        if(n==0) break;
        int p = n;
        vector<int> score;
        cin >> s;
        n--;
        score.push_back(s);
        int mins=s,maxs=s,result=0;
        while(n--){
            cin >> s;
            maxs = max(maxs,s);
            mins = min(mins,s);
            score.push_back(s);
        }
        vector<int>::iterator it;
        it = score.begin();
        while(it != score.end()){
            bool maxf=false,minf=false;
            if (((*it)==mins) && (minf == false)) {
                minf = true;
            }
            else if(((*it)==maxs) && (maxf == false)){
                maxf = true;
            }
            else{
                result += (*it);
            }
            it++;
        }
        cout << result/(p-2) << endl;
    }
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int n;
	while(n=read()){
		int score[n];
		int mean=0;
		REP(i,n){
			score[i] = read();
		}
		
		sort(score,score+n);

		
		FOR(i,1,n-1){
			mean += score[i];
		}
		mean /= (n-2);
		cout << mean << endl;
	}
}

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

int main()
{
	int n, a, b;
	while(1){
		std::cin >> n;
		if(n == 0) break;
		int max = -1, min = 1001, sum = 0;
		for(int i = 0; i < n; i++){
			std::cin >> a;
			if(a > max) max = a;
			if(a < min) min = a;
			sum += a;
		}
		b = (sum - max - min) / (n - 2);
		std::cout << b << std::endl;
	}
	return 0;
}

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

vector<int> v;

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

    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void) {
	int n[20], s[20][100], sum[20], shift;
	int j = 0;
	while (1) {
		sum[j] = 0;
		cin >> n[j];
		if (n[j] == 0)
			break;

		for (int i = 0; i < n[j]; i++) {
			cin >> s[j][i];
		}

		// 昇順ソート
		for (int i = 0; i < n[j]; i++) {
			for (int t = i + 1; t < n[j]; t++) {
				if (s[j][i] > s[j][t]) {
					shift = s[j][i];
					s[j][i] = s[j][t];
					s[j][t] = shift;
				}
			}
		}
		for (int i = 1; i < n[j] - 1; i++) {
			sum[j] += s[j][i];
		}
		sum[j] = sum[j] / (n[j] - 2);
		cout <<  sum[j] << endl;
		j++;

	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int s[100][100];
	int sum[100];
	int change;
	int n=1;
	int i, t,j;
	j = 0;
	while (n)
	{
		sum[j] = 0;
		scanf("%d", &n);
		for (i = 0; i < n; i++)
		{
			scanf("%d", &s[j][i]);
		}
		for (i = 0; i < n; i++)
		{
			for (t = i; t < n; t++)
			{
				if (s[j][i] < s[j][t])
				{
					change = s[j][i];
					s[j][i] = s[j][t];
					s[j][t]=change;
				}
			}
		}
		for (i = 1; i < n - 1; i++)
		{
			sum[j] += s[j][i];
		}
		sum[j] = sum[j] / (n - 2);
		j++;
	}
	for (i = 0; i < j-1; i++)
	{
		printf("%d\n", sum[i]);
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) {
      break;
    }
    vector<int> a(n);
    for(int i=0;i<n;++i) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    int su = 0;
    for(int i=1;i<n-1;++i) {
      su += a[i];
    }
    cout << su / (n - 2) << endl;
  }

}

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

int main()
{
	int x[100], i, j = 0, n = 1, sum[100];
	while (1)
	{
		sum[j] = 0;
		cin >> n;
		if (n == 0)
			break;

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

}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll T[i];
  ll sum=0;
  for(ll i=0; i<N; ++i){
    cin>>T[i];
    sum+=T[i];
  }
  cout<<sum/N<<endl;
  
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int MIN,MAX,n,sum,a,i;
int main(){
while(true){
cin>>n;if(!n){break;}
MIN=10000000;
MAX=0;sum=0;
for(i=0;i<n;i++){cin>>a;MIN=min(MIN,a);MAX=max(MAX,a);sum+=a;}
cout<<sum-MIN-MAX<<endl;
}
}

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

int main() {
	while(true){
		int number;			//?????£??????????????°
		cin >> number;
		if(number == 0){return 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 <iostream>
using namespace std;
int main() {
  int a,n,sum,min,max,i;
  while(1){
  cin >>n;
  if (n==0){
    break;
  }
  cin >>min;
  sum=min;
  max=min;
  for (i=0;i<n-1;i++){
    cin>>a;
    sum=sum+a;
    if(min>a){
      min=a;
    }
    if(max<a){
      max=a;
    }
  }
  cout <<(sum-max-min)/(n-2)<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main() {

	int n=0;
	int s=0;
	int result=0;
	
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> s;
		result = result + s;
	}

	cout << result;

	return 0;

}

C++: #include <iostream>
using namespace std;
int main() {
    int N,input;
    while (1){
        cin >> N;
        if (N==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<N;i++) {
            cin >> input;
            sum += input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        cout << (sum-max-min)/(N-2) <<endl;
    }
    return 0;
}