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<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n,s,sum,mi,ma;
	int i;
	while (cin >> n) {
		sum = 0;
		ma = 0; mi = (int)MOD;
		if (n == 0)break;
		for (i = 0; i < n; i++) {
			cin >> s; sum += s; mi = min(mi, s); ma = max(ma, s);
		}
		sum -= ma + mi;
		cout << sum / (n-2) << endl;
	}
	return 0;
}

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

int main()
{
	int n, point[100], sum = 0, ave = 0, max = 0, min = 0;
	while( cin >> n && n != 0){

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

		sort(point, point + n);


		for(int i = 1; i < n-1; i++){
			sum += point[i];
		}
		ave = sum / (n-2);
		cout << ave << endl;

		sum = 0;
		ave = 0;
		min = 0;
		max = 0;
	}

	return 0;
}

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

int main() {
	int nn = 0;
	int ans[100];
	while (1) {
		int n, maxn, minn;
		int pn = 0;
		cin >> n;
		if ( n == 0 ) break;
		int s[n];
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			if ( i == 0 ) {
				maxn = s[0];
				minn = s[0];
			} else {
				if ( s[i] > maxn ) maxn = s[i];
				if ( s[i] < minn ) minn = s[i];
			}
			pn += s[i];
		}
		ans[nn] = (pn - maxn - minn) / (n - 2);
		nn++;
	}
	for ( int i = 0; i < nn; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		sort(Vec.begin(), Vec.end());
		int sum = 0;
		for(int i = 1; i < Vec.size() - 1; ++i)
		{
			sum += Vec[i];
		}
		cout << sum / (Vec.size() - 2) << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

int main(){
	int n;
	while(cin>>n && n!=0){
		vector <int> a;
		for(int i=0;i<n;i++){
			int b;
			cin>>b;
			a.push_back(b);
		}
		sort(a.begin(),a.end());

		int ans=0;
		for(int i=0;i<n-2;i++){
			ans+=a[i+1];
		}
		cout<<ans/(n-2)<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

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

C++: #include<stdio.h>

int main(){
	int max = -1;
	int min = 1000;
	int ans = 0;
	int loop = 0;
	int i,buf;
while(true){
	scanf("%d",&loop);
	if(loop == 0){
		break;
	}
	for(i=0;i<loop;i++){
		scanf("%d",&buf);
		if(max < buf){
			max = buf;
		}
		if(min > buf){
			min = buf;
		}
		ans += buf;
	}
	ans -= (max + min);
	printf("%d\n",buf/(loop-2));
}
}

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

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

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>
#include<climits>
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;
	int b;
	int c = INT_MAX;
	while (true){
		cin >> N;
		if (N == 0){ break; }
		if (c != INT_MAX){ cout << endl; }
		REP(i, N){
			cin >> b;
			S.push_back(b);
		}
		c = getAverageScore(N, S);
		cout << c;
		S.clear();
	}
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;

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

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

int main(int argc, char const* argv[])
{
  while (true) {
    int n;
    std::cin >> n;
    if (n == 0) {
      break;
    }
    std::vector<int> scores(n);
    for (int i = 0; i < n; ++i) {
      int s;
      std::cin >> s;
      scores[i] = s;
    }
    std::sort(scores.begin(), scores.end());
    scores.erase(scores.begin());
    scores.pop_back();
    int sum = std::accumulate(scores.begin(), scores.end(), 0);
    std::cout << (sum / (n - 2)) << std::endl;
  }
  return 0;
}