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;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int in;
    int num;
    int ans=0;
    int point[105]={};
    while(1==1)
    {
        
        scanf("%d\n",&in);
        if(in==0)return 0;
        num=in;
        ans=0;
        REP(i,num)
        {
            scanf("%d\n",&point[i]);
            ans+=point[i];
        }
        sort(&point[0],&point[num]);
        ans-=(point[0]+point[num-1]);
        printf("%d\n",ans/num);
    }
    return 0;
}

C++: #include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        vector<int> score(n);
        int sum = 0, ma = 0, mi = 1500;
        for(int i = 0 ; i < n ; i++){
            cin >> score[i];
            sum += score[i];
            ma = max(ma, score[i]);
            mi = min(mi, score[i]);
        }
        sum -= (ma + mi);
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

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

int main() {
	int n, max, min, s;
	long sum;

	while (true) {
		cin >> n;
		sum = max = 0;
		min = 1000;

		if (n == 0)	break;

		for (int i = 0; i < n; i++) {
			cin >> s;
			if (s < min)	min = s;
			if (s > max)	max = s;
			sum += s;
		}
		sum -= (min + max);
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    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 ans = 0;
        for(int i = 1; i < n - 1; i++)
        {
            ans += v[i];
        }
        ans /= n - 2;
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		int a[n];
		int M=0,m=1e5;
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		int sum=0;
		for(int i=0;i<n;i++){
			M=max(a[i],M);
			m = min(a[i],m);
			sum+=a[i];
		}
		sum-=(M+m);
		cout<<sum/(n-2)<<endl;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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 LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int n,i,s,sum;
	vi v;
	while(1){
		cin>>n;
		if(n==0)break;
		
		v.clear();
		rep(i,n){
			cin>>s;
			v.push_back(s);
		}
		sort(v.begin(),v.end());
		sum=0;
		for(i=1;i<n-1;i++){
			sum+=v[i];
		}
		cout<<sum/(n-2)<<endl;
	}
	
	
	
	
	
	
//////////////////////////////////////////////////////
return 0;}

C++: #include<iostream>
using namespace std;
int main(){
while(true){
int n;
cin >> n;
if(n == 0)return 0;
int a[n];
for(int i = 0; i < n; i++)
cin >> a[i];

int max = 0;
int min = 1000;
int sum = 0;

for(int i = 0 ; i < n ; i++){
	if(a[i] > max)
	max = a[i];
	if (a[i] < min)
	min = a[i];
	sum += a[i];
}
cout << (sum-max-min)/(n-2);

}
}

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

int n;

int main(){
  int ave;
  while(cin >> n && (n > 0)){
  int a[100];
  int sum = 0;
  for (int i = 0; i <= n-1; i++){
   cin >> a[i];
   }
   sort(a, a+n);
   for (int j=1; j <= n-2; j++){
     sum += a[j];
	 }
   ave = floor(sum / (n-2));
   cout << ave << endl;
	}
 }

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

using namespace std;

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    vector<int> score(n);
    for(int i=0;i<n;i++)cin>>score[i];

    vector<int>::iterator minIt = min_element(score.begin(),score.end());
    int minIndex = distance(score.begin(),minIt);
    score.erase(score.begin()+minIndex-1);

    vector<int>::iterator maxIt = max_element(score.begin(),score.end());
    int maxIndex = distance(score.begin(),maxIt);
    score.erase(score.begin()+maxIndex-1);

    int sum = accumulate(score.begin(),score.end(),0);
    cout << sum/score.size() << endl;
  }
  return 0;
}

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

using namespace std;

int main(void){

  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++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <math.h>
#include <string.h>
#include <stack>
#include <cctype>

using namespace std;


int main(){

	while(1){
		int n,s,sum,max,min;

		cin>>n;
		if(n==0) break;

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

	return 0;
}

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

int main() {
    int N;
    while (1) {
        cin >> N;
        if (N == 0) break;
        vector<int> score(N);

        for (int i = 0; i < N; i++) {
            cin >> score[i];
        }
        sort(score.begin(), score.end());

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