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>
#include <algorithm>

using namespace std;

int main(void) {
    vector<int> vec;
    int n_data, in;
    for (;;) {
	scanf("%d", &n_data);
	if (n_data == 0)
	    return 0;

	for (int i = 0; i < n_data; ++i) {
	    scanf ("%d", &in);
	    vec.push_back(in);
	}
	sort(vec.begin(), vec.end());

	int ave = 0;
	for (auto it = vec.begin() + 1; it < vec.end() - 1; ++it)
	    ave += *it;
	printf("%d\n", ave / (n_data - 2));
	vec.clear();
    }
}

C++: #include<iostream>

using namespace std;

int main () {

  while (true){

    int n;
    int i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0) break;
??????
??????int p[100];

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

      if (p[i] < mi;)
        mi << p[i];

      if (p[i] > ma;)
        ma << p[i];

      s += p[i];

    }

    cout << (s - mi - ma) / (n-2) << endl;

  }

  return 0;

}

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

int main(){
    int n;
    int high,low;
    int hi,lo;
    int total;
    int cnt;
    int point[100]={0};
    while(1){
        total = 0;
        cnt = 0;
        cin >> n;
        if(n == 0) break;
        for(int i=0;i<n;i++){
            cin >> point[i];
            if(i == 0){
                high = point[i];
                low = point[i];
                hi = 0;
                lo = 0;
            }
            else if(point[i] > high){
                high = point[i];
                hi = i;
            }
            else if(point[i] < low){
                low = point[i];
                lo = i;
            }
        }
        for(int i=0;i<n;i++){
            if(i != hi && i != lo){
                total += point[i];
                cnt++;
            }
        }
        cout << total / cnt << endl;
    }
}

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

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

    int sum = 0, minv = 100000, maxv = -1;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      if (s < minv) minv = s;
      if (s > maxv) maxv = s;
      sum += s;
    }
    sum -= minv + maxv;
    int ave = sum / (n - 2);
    
    cout << ave << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		vi a(n);
		for(int i=0;i<n;i++) cin>>a[i];
		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 <iostream>
#include<algorithm>
using namespace std;
int main() {
	while (true) {
		int n;
		cin >> n;
		int sum = 0;
		int ma = 0;
		int mi = 100000;
		for (int i = 0; i < n; i++) { int s; cin >> s; sum += s; ma = max(ma, s); mi = min(mi, s); }
		cout << (sum - mi - ma) / (n - 2) << endl;
	}
}

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

int main()
{
	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 sum = 0;
		for (int i = 1; i < n-1; i++) {
			sum += v[i];
		}
		cout << sum / (n-2) << endl;
	}
	
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>

using namespace std;
const int INF = (1<<30);
typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)

int sx, sy;

int gx, gy;

int qqq;

//各座標までの最短距離
int d[100][100];


//移動方向のベクトル
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

//汎用
ll ans = 0;
pair<int, int> red[101], blue[101];
ll BIG = 10000000000;

//累乗
ll POW(ll a, ll b) {
ll c = 1;
for (int i = 0; i < b; ++i) {
c *= a;
}
return c;
}

//階乗
int Kaijou(int a) {
if (a < 2) return 1;
return a * Kaijou(a - 1);
}


int A[200000];
int kinds[200001];


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

		vector<int> s(n);
		rep(i, n) cin >> s[i];
		sort(s.begin(), s.end());
		int sum = 0;
		for (int i = 1; i < n - 1; ++i)
			sum +=s[i];
		int ave = sum / (n - 2);
		cout << ave << endl;
	}
	cin >> qqq;
}

C++: #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;
ll mod2 = 998244353;

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

C++: #include <stdio.h>
int main() {
    for(int x=0;x<1000;x++){
	int a = 0;
	scanf("%d", &a);
	int g[1000] = {};
	for (int i = 0; i < a; i++) {
		scanf("%d", &g[i]);
	}
	int sd = 0;
	int ss = 0;

	sd = g[1];
	ss = g[1];
	for (int i = 0; i < a; i++) {
		if (g[i] > sd) {
			sd = g[i];
		}
		if (g[i] < ss) {
			ss = g[i];
		}
	}
	int g1 = 0;
	for (int i = 0; i < a; i++) {
		g1 = g1 + g[i];
	}
	int g2 = 0;
	g2 = g1 - sd - ss;
	a = a - 2;
	g2 = g2 / a;
	if(g2==0){
	    
	}else {
	printf("%d\n", g2);
	}
}
return 0;
}