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 <cstdio>
#include <vector>
using namespace std;

int main()
{
int n;
vector<int> s;
scanf("%d", &n);
s.resize(n);
for(int i = 0; i < n; ++i)
scanf("%d", &s[i]);
sort(s.begin(), s.end());
int sum = 0;
for(int i = 1; i < n - 1; ++i)
sum += s[i];
printf("%d\n", sum / (n - 2));
return 0;
}

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

C++: #include<iostream>

using namespace std;

const int calc(int*, int);


int main(){

	int data[100] = {};
	int count = 0;
	while (true){
		cin >> count;
		if (count == 0)break;
		for (int i = 0; i < count; i++){
			cin >> data[i];
		}

		for (int i = 1; i < count; i++){
			for (int j = i; j > 0; j--){
				if (data[j - 1] > data[j]){
					int tmp = data[j];
					data[j] = data[j - 1];
					data[j - 1] = tmp;
				}
			}
		}
		cout << calc(data, count) << endl;
	}

	return 0;
}

const int calc(int* a, int count){
	if (count <= 0)return 0;

	int ave = 0;

	for (int i = 1; i < count - 1; i++)ave += a[i];
	return ave / (count - 2);
}

C++: //
//  main.cpp
//  AOJ1147
//
//  Created by aki33524 on 2014/07/15.
//  Copyright (c) 2014年 aki33524. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[])
{
    int n;
    while(cin>>n, n){
        vector<int> v(n);
        for(int i=0; i<n; i++)
            cin >> v[i];
        sort(v.begin(), v.end());
        int ans = 0;
        for(int i=1; i<n-1; i++)
            ans += v[i];
        cout << ans/(n-2) << endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
 
#define ascent(i, a, b) for(int (i) = (a); (i) < (b); (i) ++)

using namespace std;

int main() {
  int n, tmp;
  vector<int> p;
  while(true) {
    cin >> n;
    if(n == 0) break;

    p.clear();
    while(n --) {
      cin >> tmp;
      p.push_back(tmp);
    }

    sort(p.begin(), p.end());

    int sum = 0;
    ascent(i, 1, p.size()-1) {
      sum += p[i];
    }

    cout << sum/(p.size()-2) << endl;
  }
      
  return 0;
}

C++: //include
//------------------------------------------
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int getAverageScore(int N, VI S){
	int min = S[0];
	int max = S[0];
	int sum = 0;
	FOR(i, 1, N){
		sum += S[i];
		if (min > S[i]){ min = S[i]; }
		if (max < S[i]){ max = S[i]; }
	}
	sum -= (min + max);
	return sum / N;
}
int main(){
	int N;
	VI S;
	while (true){
		cin >> N;
		if (N == 0){ break; }
		REP(i, N){
			cin >> S[i];
		}
		cout << getAverageScore(N, S)<<endl;
	}
}

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

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
  return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
  os<<'[';
  rep(i,a.size()) os<<(i?" ":"")<<a[i];
  return os<<']';
}



int main() {
  for (int n; cin >> n, n != 0; ) {
    vi s(n);
    rep(i, n) cin >> s[i];

    cout << (accumulate(all(s), 0) - *max_element(all(s)) - *min_element(all(s))) / (n - 2) << endl;
  }
  
  
  return 0;
}

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

int main(){
	int n, s, sum, max, min, i;
	while((cin >> n), n){
		sum = max = 0;
		min = 1000;
		for(i = 0; i < n; i++){
			cin >> s;
			sum += s;
			max = max(max, s);
			min = min(min, s);
		}
		cout << (int)(sum / n) << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  while (cin >> n && n) {
    int mx = -1;
    int mn = 1001;
    int sum = 0;
    REP(i, n) {
      int s;
      cin >> s;
      sum += s;
      if (mx < s) mx = s;
      if (s < mn) mn = s;
    }
    int ans = (sum - (mx + mn)) / (n - 2);
    cout << ans << endl;
  }
  return 0;
}