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>

#define FOR(i,l,n) for(int i=(l);i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX_JUDGE 100
using namespace std;

int main(){
  int n,score[MAX_JUDGE];
  while(cin>>n,n){
    REP(i,n)cin>>score[i];
    sort(score,score+n);
    int sum=0;
    FOR(i,1,n-1)sum+=score[i];
    cout << sum/(n-2) <<endl;
  }
  return 0;
}

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

int main(){
  int n,s[100],num=0,max=s[0],min=s[0];

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

    if(max<s[i])max=s[i];
    if(max>s[i])min=s[i];
       
    num += s[i];
  }
  num = (num-max-min)/n;
    cout<<num<<endl;  
  return 0;
}

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

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

using namespace std;

int main(){
    vector<int> vc;
    int n;
    while(cin >> n){
        int tmp;
        vc.clear();
        REP(i,n){
            cin >> tmp;
            vc.push_back(tmp);
        }
        sort(vc.begin(), vc.end());
        vc.erase(vc.begin());
        vc.erase(--vc.end());
        int sum = 0;
        vector<int>::iterator it = vc.begin();
        while(it != vc.end()){
            sum += (*it);
            it++;
        }
        cout << sum/(n-2) << endl;
    }
    return 0;
}

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

int main(){
  int n;
  while(cin>>n && n){
    int min=1000;
    int max=0;
    int sum=0;
    for(int i=0;i<n;i++){
      int a;
      cin>>a;
      sum+=a;
      if(min > a) min = a;
      if(max < a) max = a;
    }
    cout<<(sum-min-max)/(n-2)<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
using namespace std;
int n;
int main() {
	while (cin >> n, n) {
		vector<int> v;
		for (int i = 0; i < n; ++i) {
			int a; cin >> a;
			v.push_back(a);
		}
		sort(v.begin(), v.end());
		int sum = 0;
		for (int i = 1; i < v.size() - 1; ++i) {
			sum += v[i];
		}
		cout << sum/(v.size()-2) << endl;
	}
	
	return 0;
}

C++: #include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
using namespace std;
int main(){
	int n,s,mn,mx,cnt;
	while(cin>>n){
			if(n==0){
				break;
			}
			cnt=0;
			cin>>s;
			mn=s;
			mx=s;
			cnt+=s;
		for(int i=1;i<n;i++){
			cin>>s;
			mn=min(mn,s);
			mx=max(mx,s);
			cnt+=s;
		}
		cout<<(cnt-mn-mx)/(n-2)<<endl;
	}
	return 0;
}

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

int main() {
	int N;
	while(cin>>N && N>0){
		int A[N];
		rep(i,N) cin >> A[i];
		int M = 0;
		rep(i,N){
			if (M<A[i]){
				M=A[i];
			}			
		}
		int m = 10000000;
		rep(i,N){
			if(m>A[i]){
				m=A[i];
			}
		}
		int sum =0;
		rep(i,N){
			sum += A[i];
		}
		
		sum = sum - M - m;
		int ave = sum/( N - 2);
		cout << ave<<endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll M = 0;
  vvl A(21);
  while (true) {
    ll N;
    cin >> N;
    if (N == 0)
      break;
    REP(i, N) {
      ll a = 0;
      cin >> a;
      A[M].push_back(a);
    }
    M++;
  }
  REP(i, M) {
    sort(ALL(A[i]));
    ll ans = 0;
    ll N = A[i].size();
    for (ll j = 1; j < N - 1; j++) {
      ans += A[i][j];
    }
    cout << ans / (N - 2) << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
    int n;
    while (true) {
        cin >> n;
        if (!n) { break; }

        vector<int> v(n);

        for (int i = 0; i < n; i++) { cin >> v[i]; }
        sort(v.begin(), v.end());

        int sum = 0;
        for (int i = 1; i < n-1; i++) {
            sum += v[i];
        }

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