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>
using namespace std;
int main(){
	int sinpan,a[100],i,min,max,mini,maxi,sum=0;
	while(1){
		cin>>sinpan;
		if(sinpan==0) break;
		min=1001;
		max=0;
		for(i=0;i<sinpan;i++){
			cin>>a[i];
			if(max<a[i]){
				max=a[i];maxi=i;
			}
			if(min>a[i]){
				min=a[i];mini=i;
			}
		}
		a[maxi]=-1;
		a[mini]=-1;
		for(i=0;i<sinpan;i++){
			if(a[i]!=-1)
			sum+=a[i];
		}
		sum/=(sinpan-2);
		cout<<sum<<endl;
		sum=0;
	}
		return 0;
}

C++: #include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

void solve(int N){
  vector<int> S(N);
  for(int i=0;i<N;i++) cin>>S[i];

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

  int ans=0;
  for(int i=1;i<N-1;i++) ans+=S[i];
  cout<<ans/(N-2)<<endl;
}

int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0) break;
    solve(n);
  }

  return 0;
}

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

using namespace std;

int main() {
  array<int,100> s;
  int n;
  while ((cin >> n) && n != 0) {
    for (int i=0; i<n; i++) cin >> s[i];
    int ssum = accumulate(s.begin(), s.begin()+n, 0);
    int smax = *max_element(s.begin(), s.begin()+n);
    int smin = *min_element(s.begin(), s.begin()+n);
    cout << (ssum-smax-smin)/(n-2) << endl;
  }
  return 0;
}

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

int main() {
	int i, n, tmp, sum;
	priority_queue<int> q;

	while (1) {
		cin >> n;
		if (n == 0)break;
		sum = 0;
		for (i = 0; i < n; i++) {
			cin >> tmp;
			q.push(tmp);
		}
		q.pop();
		while (q.size() > 1) {
			sum += q.top();
			q.pop();
		}
		q.pop();
		cout << sum / (n - 2) << endl;
	}

	return 0;
}

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

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,s,m,M,ans;
	while(true){
		cin>>n;
		if(n==0){
			return 0;
		}
		m = 1005;
		M= -1;
		ans=0;
		for(int i=0;i<n;i++){
			cin>>s;
			m=min(m,s);
			M=max(M,s);
			ans+=s;
		}
		n-=2;
		ans=ans-M-m;
		ans /= n;
		cout<<ans<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int p;
  int s[1000];
  int sum=0;
  while(1){
    cin>>p;
    if(p==0) break;
    for(int i=0;i<p;i++){
      cin>>s[i];
      sum+=s[i];
    }
    sort(s,s+p);
    for(int j=0;j<p;j++){
      cout<<s[j]<<endl;
    }
    /*cout<<sum-s[0]-s[p-1]<<endl;*/
  }
  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int n;
int d;

int main()
{
  while(cin >> n, n){
    int sum = 0;
    int mn = INF;
    int mx = -INF;
    rep(i, n){
      cin >> d;
      sum += d;
      minup(mn, d);
      maxup(mx, d);
    }

    cout << (sum - mx - mn) / (n - 2) << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n;
	int mmax = -1;
	int mmin = 10000;
	int tmp;
	ll int sum;
	while(cin >> n,n){
		mmax = -1;
		mmin = 10000;
		sum = 0;
		REP(i,n){
			cin >> tmp;
			mmax = max(tmp,mmax);
			mmin = min(tmp,mmin);
			sum += tmp;
		}
		cout << (int)((sum-mmax-mmin)/(n-2)) << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
int main() {
	int n;
	vector<long long>li;
	while (cin >> n) {
		if (n == 0)break;
		vector<long long>l;
		long long a;
		for (int i = 0; i < n; i++){
			cin >> a;
			l.push_back(a);
		}
		sort(l.begin(), l.end());
		long long sum = 0;
		int g = l.size();
		for (int i = 1; i < g - 1; i++){
			sum += l[i];
		}
		li.push_back(sum / (g - 2));
	}
	for (long long i : li) {
		cout << i << endl;
	}
	char c;
	cin >> c;
	return 0;
}