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

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

int main(){

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

        vector<int> s(n);
        for(int i = 0; i < n; i++){
            cin >> s[i];
        }

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

        int sum = accumulate(s.begin(), s.end(), 0);

        sum -= (s[0] + s[n - 1]);

        int ans = sum / (n - 2);
        cout << ans << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int N;
int Point[100];
int High=-1;
int Low=1001;
int main()
{
	while(true){
		scanf("%d",&N);
		if(N==0)break;
		High=-1;Low=1001;
		int sum=0;
		for(int i=0;i<N;i++){
			scanf("%d",&Point[i]);
			sum+=Point[i];
			High=max(Point[i],High);
			Low=min(Point[i],Low);
		}
		printf("%d\n",(sum-High-Low)/(N-2));
	}
}

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(100);
    while(true){
        vec.assign(100, -1);
        ans = 0;
        cnt = 0;
        cin >> N;
        if(N == 0) return 0;
        rep(i, N){
            cin >> vec[i];
        }
        vsort(vec);
        REP(i, 101 - N, 99){
            ans += vec[i];
            cnt++;
        }
        cout << (int)(ans / cnt) << endl;
    }


    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	ll n;
	while (1) {
		ll n; scanf("%lld", &n);
		if (n == 0) break;
		vector<ll> a(n); for (ll i = 0; i < n; i++) scanf("%lld", &a[i]);
		sort(a.begin(), a.end());
		ll sum = 0;
		for (ll i = 1; i < n - 1; i++) sum += a[i];
		sum /= (n - 2);
		printf("%lld\n", sum);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int N,S;

int main() {
	while (cin >> N && N>0) { // By while (), adopt the form of std in 
		int sum = 0;
		int max = 0;
		int min = 0;
		for (int i=0; i<N; i++) {
			cin >> S;
			sum += S; // calculate sum
			if (max < S) max = S; // search max
			if (min > S) min = S; // search min
		}
		int ans;
		ans = (sum-max-min)/(N-2);
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(){
    
    // 各種変数宣言
    
    int n,x,y,i,j,k,c,a,p=0;
    int min,max,answer,carda[100];
    // 配列宣言
    
    
    // メインループ
    
    while(1){
        int card[500]={};
        
        // nとpを読み込む
        scanf("%d", &n);
        if(n==0)break;
        
        for(i=0;i<n;i++){
        scanf("%d", &card[i]);
        }
        
        min=1001;
        for(i=0;i<n;i++){
            if(min>card[i] || min==card[i]){
                min=card[i];
                x=i;
            }
        }
        
        max=0;
        for(i=0;i<n;i++){
            if(max<card[i] || max==card[i]){
                max=card[i];
                y=i;
            }
        }
        
        
        card[x]=0;
        card[y]=0;
        k=0;
        for(i=0;i<n;i++){
            k+=card[i];
        }
        
        answer=k/(n-2);
        carda[p]=answer;
        p++;
    }
    for(i=0;i<p;i++){
        printf("%d\n",carda[i]);
    }
    // 終了
    return 0;
    
}

C++: #include<iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
//1147
using namespace std;
int a,b,maxa=0,mina=10000,tot=0;
double ans;
	int main(){
		while(cin>>a){
			if(a==0){
			break;}
			for(int i=0;i<a;i++){
			cin>>b;
			tot+=b;
			if(maxa<b){maxa=b;}
			if(mina>b){mina=b;}}
			ans=(tot-maxa-mina)/(a-2);
		cout<<floor(ans)<<endl;
		tot=0;mina=10000;maxa=0;}
		return 0;}

C++: #include<iostream>
using namespace std;
int main(){
	int n,x,max,min,pre;
	while(cin>>n,n){
		cin>>x;
		pre=x;
		max=x;
		min=x;
		for(int i=0;i<n-1;i++){
			cin>>x;
			pre+=x;
			if(max<x)
				max=x;
			if(min>x)
				min=x;
		}
		cout<<(pre-max-min)/(n-2)<<endl;
		
		
		
		
	}
	return 0;
}

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

int main(){
	int S[1005];
	int n,sum;
	while(1){
		cin>>n;
		if(n==0) break;
		sum=0;
		for(int i=0;i<n;i++) cin>>S[i];
		sort(S,S+n);
		for(int i=1;i<n-1;i++) sum+=S[i];
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

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

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

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define REP(i,k,n) for(int i = k; i < n; i++)

#define vi vector<int>
#define pb push_back
using namespace std;
typedef long long ll;

int main(){
    int n;
    while(cin >> n,n) {
        vi a;
        int tmp;
        rep(i,n){
            cin >> tmp;
            a.pb(tmp);
        }
        sort(a.begin(),a.end());
        ll sum = 0;
        REP(i,1,n - 1){
            sum += a[i];
        }
        cout << sum / (n - 2) << endl;
    }
    return 0;
}