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

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

using namespace std;

int main(){
  int n;
  while(cin>>n,n!=0){
    vector<int> score(n);
    rep(i,n)cin>>score[i];

    vector<int>::iterator minIt = min_element(score.begin(),score.end());
    int minIndex = distance(score.begin(),minIt);
    score.erase(score.begin()+minIndex-1);

    vector<int>::iterator maxIt = max_element(score.begin(),score.end());
    int maxIndex = distance(score.begin(),maxIt);
    score.erase(score.begin()+maxIndex-1);

    int sum = accumulate(score.begin(),score.end(),0);
    cout << sum/score.size() << endl;
  }
  return 0;
}

C++: #include <iostream>
#define INF (2<<29)
using namespace std;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    for(;;){
        int a,n,s=0,max=0,min=INF;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            s+=a;
            if(max<a) max=a;
            if(min>a) min=a;
        }
        cout<<(s-max-min)/(n-2)<<endl;
    }
    return 0;
}

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

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef complex<int> P;
typedef pair<int,int> pii;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
template <class F, class T> void convert(const F &f, T &t){	stringstream ss; ss << f; ss >> t;}


bool solve(int n){
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>> a[i];
	
	sort(all(a));
	int ans = 0;
	for(int i=1;i<n-1;i++) ans += a[i];
	ans /= n-2;
	
	cout<< ans<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed); cout.precision(10);
	int n;
	while(cin>> n, n){
		solve(n);
	}
	return 0;
}

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

using namespace std;

#define MAX 100

int n, s[MAX];

int main() {
	while (1) {
		scanf("%d", &n);
		if (n == 0)
			return 0;

		for(int i = 0; i < n; i++)
			scanf("%d", s + i);
		sort(s, s + n);

		int ans = 0;
		for(int i = 1; i < n - 1; i++)
			ans += s[i];

		printf("%d\n", ans / (n - 2));
	}
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		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());
		int sum = 0;
		for (int i = 1; i < n - 1; i++) sum += s[i];
		cout << sum / (n - 2) << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int solve(int );

int main(void){
  int N;

  while(1) {
    cin>>N;
    if(N==0) return 0;
    else solve(N);
  }
  return 0;
}

int solve(int N){
  vector<int> score(N);
  FOR(i,0,N){
    cin>>score[i];
  }
  sort( score.begin(),score.end() );

  int sum;
  FOR(i,1,N-1){
    sum += score[i];
  }
  int ans = sum/(N-2);
  cout<<ans<<endl;
  sum=0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

int main(void) {
	int N;
	while (cin >> N, N) {
		vector<int> score(N);
		for (int i = 0; i < N; i++)
			cin >> score[i];
		sort(score.begin(), score.end());
		
		int sum = 0;
		for (vector<int>::iterator it = score.begin() + 1; it != score.end() - 1; it++)
			sum += *it;
		int avg = sum / (N - 2);

		cout << avg << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int i,N,total=0,maxdayo,mindayo,box[1000];
  while(1){
  cin>>N;
  if(N==0) break;
  else{
  for(i=0;i<N;i++){
    cin>>box[i];
  }
  maxdayo=0;
  mindayo=1000;
  for(i=0;i<N;i++){
    total+=box[i];
    maxdayo=max(box[i],maxdayo);
    mindayo=min(box[i],mindayo);
  }
  total=total-maxdayo-mindayo;
  cout<<total/(N-2)<<endl;
  }
  total=0;
  }
  return 0;
}

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

int N, S;

int main()
{
   while ( cin >> N && N>0)
   {
      int M, m, addup, i;
      M = -1;
      m = 1001;
      addup = 0;
      for ( i = 0; i<N; i++)
      {
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   cout << (addup - M - m)/(N-2)  << endl;
   }
}