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 N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<(N-1); ++j){
    Max=A[0];
	if(A[j+1]>A[j]) Max=A[j+1];
    }
  for (int k=0; k<(N-1); ++k){
    Min=A[0];
	if(A[k+1]<A[k]) Min=A[k+1];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(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) {
    if (n == 0) break;

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

C++: #include<stdio.h>
int main(){
  int a,b,c,d,i,j=0,dt[1000],ls[1000],max,min,l,sum;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    sum=0;
    max=0;
    min=10000;
    for(i=0;i<a;i++){
      scanf("%d",&b);
      dt[i]=b;
    }
    for(i=0;i<a;i++){
      if(dt[i] > max) max=dt[i];
      if(dt[i] < min) min=dt[i]; 
    } 
    for(i=0;i<a;i++){
      if(dt[i]==max) 
	max=0;
      else if(dt[i]==min)
	min=0;
      else sum+=dt[i];
    }
    ls[j]=sum/(a-2);
    j++;
  }
  for(l=0;l<j;l++)
    printf("%d\n",ls[l]);
  return 0;
}

C++: #include <iostream>

using namespace std;


int main(void) {
    int n;
    int score, sum_score;
    int max_score, min_score;
    int i;

    cin >> n;
    while (n) {
        sum_score = 0;
        max_score = 0;
        min_score = 1000;
        for (i=0; i<n; i++) {
            cin >> score;
            sum_score += score;
            if (score < min_score) {
                min_score = score;
            }
            if (score > max_score) {
                max_score = score;
            }
        }

        sum_score -= min_score + max_score;
        cout << sum_score / (n-2) << endl;

        cin >> n;
    }

    return 0;
}

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

int main()
{
  int n;
  while(cin >> n){
    if(n == 0) break;
    int sum = 0;
    int s[100];
    for(int i = 0; i < n; i++)
      cin >> s[i];
    sort(s, s + n);
    for(int i = 1; i < n - 1; i++)
      sum += s[i];
    cout << sum / (n - 2) << endl;
  }
}

C++: #include <stdio.h>
#include <algorithm>

int main(void)	{
	while (true)	{
		int umpire, temp, summ, mini, maxi;
		mini = 1000;
		maxi = 0;
		summ = 0;
	
		scanf("%d", &umpire);
		if (umpire == 0)	{
			break;
		}
		for (int i = 0; i <= umpire - 1; i++)	{
			scanf("%d", &temp);
			mini = std::min(mini, temp);
			maxi = std::max(maxi, temp);
			summ = summ + temp;
		}
		printf("%d\n", (summ - mini - maxi) / (umpire - 2));
	}
	return 0;	
}

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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double EPS = 1e-9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n;
int s[100];

int main() {
	// cin.tie(0); // tie
	// ios::sync_with_stdio(false); // sync
	while (cin >> n, n) {
		int mini = 10000, maxi = -1;
		int sum = 0;
		rep(i, n) {
			int s; cin >> s;
			if (mini > s) mini = s;
			if (maxi < s) maxi = s;
			sum += s;
		}
		int av = (sum - mini - maxi) / (n - 2);
		cout << av << endl;
	}
	return 0;
}

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

int main()
{
	int n;
	for (; cin >> n, n != 0;)
	{
		int sum = 0;
		int max = -1;
		int min = 1001;
		int s[100];
		for (int i = 0; i < n; i++)
		{
			cin >> s[i];
			max = (max < s[i]) ? s[i] : max;
			min = (min > s[i]) ? s[i] : min;
			sum += s[i];
		}
		cout << (sum - (max + min)) / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n==0)break;
    vector<int> p(n);
    int sum=0;
    rep(i,n){
      cin >> p[i];
      sum += p[i];
    }
    int min,max;
    min=*min_element(p.begin(),p.end());
    max=*max_element(p.begin(),p.end());
    sum -= (max+min);
    int avg = sum / (n-2);
    cout << avg << endl;
  }
  return 0;
}

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int N,input;
    while (1){
        scanf("%d", &N);
        if (N==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<N;i++) {
            cin >> input;
            sum = sum+input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        printf("%d\n", (sum-max-min)/(N-2));
    }
}