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<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 1005
int a[ARRAY_MAX];

int main(){

    int n;
    while(cin >> n,n){

        int maxi = -1;
        int mini = INF;
        vector<int> a(n);
        REP(i,n){
            cin >> a[i];
        }
        VSORT(a);
        int sum = 0;
        for(int i = 1;i < n-1;i++){
            sum += a[i];
        }
        cout << sum/(n-2) << endl;
    }
    
    
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
if(judge != 0){
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    vi a(n);
    ll sum = 0;
    rep (i, n){
      cin >> a[i];
      sum += a[i];
    }
    sort(all(a));
    sum -= a[0] + a.back();
    cout << sum / (n - 2) << endl;
  }
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	int n;

	while (cin >> n&&n) {
		int s[100];
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		for (int i = 0; i < n - 1; i++) {
			for (int j = n - 1; j > i; j--) {
				if (s[j] > s[j - 1])swap(s[j], s[j - 1]);
			}
		}
		int sum = 0;
		for (int k = 1; k < n - 1; k++)sum += s[k];
		cout << sum / (n-2) << endl;
	}
	return 0;
}

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

int main(){
  while(true){
    int njudge = 0;
    cin >> njudge;
    if(njudge == 0)return 0;
    int max=0;
    int min=10000;
    int ave=0;
    int sum=0;
    for(int i = 0 ; i<njudge ; i++){
      int input;
      cin >> input;
      if(max < input)max = input;
      if(min > input)min = input;
      sum += input;
    }
    sum -= min;
    sum -= max;
    njudge -= 2;
    ave = sum/njudge;
    cout << ave << endl;
  }
  return 0;
}

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

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

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int num;
while(true)
{
int ans = 0;
cin >> num;
if(num != 0)
{
int a[num];
for(int i = 0;i<num;i++)
{
 cin >> a[i];
}
sort(a, a + num);
for(int i=1; i<num-1;i++)
{
ans += a[i];
}
cout << ans / (num - 2) << endl;
}
else
{
return 0;
}
}
}

C++: #include <stdio.h>

int n;	//審判数
int sum;
int max;
int min;
	
void fun_max(int i, int j);
void fun_min(int i, int j);
	
int main()
{
	scanf("%d", &n);
	//printf("n=%d", n);
	
	while (n)
	{
		int i;
	
		sum = 0;
		max = -1;
		min = 1500;
		
		for (i=0; i<n; i++)
		{
			int input;
			
			scanf("%d", &input);
			//printf("input=%d\n", input);
			fun_max(max, input);
			//printf("max=%d\n", max);
			fun_min(min, input);
			//printf("min=%d\n", min);
			sum += input;
		}
		sum -= max;
		sum -= min;
		
		int ans;
		ans = sum/(n-2);
		printf("%d\n", ans);
		//printf("\n\n\n\n");
		
		scanf("%d", &n);
	}
	
	return 0;
}

void fun_max(int i, int j)
{
	if (i > j)
	{
		max = i;
	}
	else
	{
		max = j;
	}
	return;
}

void fun_min(int i, int j)
{
	if (i < j)
	{
		min = i;
	}
	else
	{
		min = j;
	}
	return;
}

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

int main(){
	int N,S;
	while(cin>>N,N){
		int sum=0,min_=INT_MAX,max_=INT_MIN;
		for(int i=0;i<N;i++){
			cin>>S;
			min_ = min(min_,S);
			max_ = max(max_,S);
			sum += S;
		}
		printf("\t%d\n",(sum-min_-max_)/(N-2));
	}
	return 0;
}