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 "bits/stdc++.h"
using namespace std;

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

signed main() {
	int n; 
	while (cin >> n && n) {
		V v(n); input(v);
		cout << (accumulate(all(v), 0) - *max_element(all(v)) - *min_element(all(v))) / (n - 2) << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int n;
	while (cin >> n && n) {
		vector<int> d(n);
		int sum = 0;
		for (int i = 0; i < n; ++i) cin >> d[i];
		sort(d.begin(), d.end());
		for (int i = 1; i < n - 1; ++i) sum += d[i];
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    vector<int> a;
    while(cin>>n){
        if(n==0)break;
        a.clear();
        for(int i = 0; n > i; i++){
            int tmp;cin>>tmp;
            a.push_back(tmp);
        }
        sort(a.begin(),a.end());
        int sm = 0;
        for(int i = 1; a.size()-1 > i; i++){
            sm += a[i];
        }
        cout << sm/(n-2) << endl;
    }
}

C++: #include <iostream>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

using namespace std;

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

C++: #include<iostream>

#define     MIN_POINT     0
#define     MAX_POINT     1000

using namespace std;

int main(){
	int n;

	// ループ
	cin >> n;
	while(n >= 3){
		int min = (int)(MAX_POINT), max = (int)(MIN_POINT);
		int sum = (min + max) * (-1);
		int i, buf;

		// 点数の入力・合計処理
		for(i=0;i<n;i++){
			// 入力
			cin >> buf;
			// 入力値のチェック
			if((buf < ((int)(MIN_POINT))) || (buf > ((int)(MAX_POINT)))){
				cerr << "入力された値が範囲外です" << endl;
				i--;
				continue;
			}
			// 合計値に加算
			sum += buf;
			// 最大値のチェック
			if(buf > max){
				sum += max;
				max = buf;
				sum -= max;
			}
			// 最小値のチェック
			if(buf < min){
				sum += min;
				min = buf;
				sum -= min;
			}
		}

		// 合計の表示
		cout << (sum / (n - 2)) << endl;

		// 入力
		cin >> n;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int N;
    int ans;
    int cnt;
    vi vec(20);
    while(true){
        vec.assign(20, -1);
        ans = 0;
        cnt = 0;
        cin >> N;
        if(N == 0) return 0;
        rep(i, N){
            cin >> vec[i];
        }
        vsort(vec);
        REP(i, 21 - N, 19){
            ans += vec[i];
            cnt++;
        }
        cout << (int)(ans / cnt) << endl;
    }


    return 0;
}

C++: #include <iostream>

using namespace std;

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

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

using namespace std;

int main(int, char**){
	int n;
	vector<int> ret;
	while(true){
		int n,buf;
		vector<int> scores;
		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; ++i){
			cin >> buf;
			scores.push_back(buf);
		}
		scores.erase(max_element(scores.begin(),scores.end()));
		scores.erase(min_element(scores.begin(),scores.end()));
		ret.push_back( std::accumulate(scores.begin(), scores.end(), 0) / scores.size() );
	}

	for(int av : ret){
		cout << av << endl;
	}
	return 0;
}

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

int main(){
int num,temp;

while(1){
   cin>>num;
   if(num==0){
   break;
   }
   int min=10000000,max=0,sum=0;
   for(int i=0;i<num;i++){
   cin>>temp;
   if(min>temp)min=temp;
   if(max<temp)max=temp;
   sum+=temp;
   }
   sum=sum-max-min;
   cout<<sum/(num-2)<<endl;
}

return 0;
}

C++: #include<iostream>
 
using namespace std;
 
int main(){
 
  int n;
 
  while(cin>>n){
 
 
 
    if(n==0){
      break;
    }
    int a[n];
    int max,min;
 
    max=0;
    min=1000;
 
    for(int i=0;i<n;i++){
      cin>>a[i];
 
      if(a[i]>max){
    max=a[i];
      }
 
      if(a[i]<min){
    min=a[i];
      }
    }
 
    int sum;
 
    sum=0;
 
    for(int p=0;p<n;p++){
      sum=sum+a[p];
    }
 
    sum=sum-max-min;
 
   
 
    cout << sum/(n-2) << endl; 
 
    
 
  }
 
   
 
 
 
  return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int n,a,sum,ma,mi;
  while(scanf("%d",&n),n){
    sum = 0;
    ma = 0;
    mi = 1001;
    for(int i=0;i<n;i++){
      scanf("%d",&a);
      sum += a;
      ma = max(ma,a);
      mi = min(mi,a);
    }
    sum -= ma+mi;
    printf("%d\n",sum/(n-2));
  }
  return (0);
}