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 FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define UNIQUE(o) (o).erase(unique(sort(all((o)))))

typedef long long ll;
const int N = 100;
const int S = 1000;
int n;
int c[S+1];

int main() {
  int s;
  scanf("%d ", &n);
  while (n) {
    memset(c, 0, sizeof(c));
    int res = 0;
    int max_idx = 0, min_idx = S;
    REP(i,n) {
      scanf("%d ", &s);
      c[s]++;
      max_idx = max(max_idx, s);
      min_idx = min(min_idx, s);
      res += s;
    }
    res -= max_idx;
    res -= min_idx;
    n -= 2;
    res /= n;
    printf("%d\n", res);
    scanf("%d ", &n);
  }

  return 0;
}

C++: #include <iostream>

using namespace std;
int main(){
	int zero;
	while(1){
		
		int N;
		int* score;
		int S = 0;
		int max = 0;
		int min = 0;
	
		cin >> N;
		
		if(N == 0){
			return 0;
		}
		
		score = new int[N];
		for(int i=0; i<N; ++i){
			cin >> score[i];
			S += score[i];
			
			if( i == 0 ){
				max = min = score[i];
			}
		
			if( max < score[i] ){
				max = score[i];
			}
			if( min > score[i] ){
				min = score[i];
			}
		}
		S -= max;
		S -= min;
	
		cout << (int)S/(N-2) << endl;

		delete[] score;
	}

}

C++: #include<bits/stdc++.h>
using namespace std;
#define OUT(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int BA = 1000;
const int INFTY = (1<<21);
int main(){
  int n,ans;
  int s[1001];
  while(cin>>n&&n){
    ans = 0;
    for(int i=0;i<n;i++)cin >> s[i];
    
    sort(s,s+n);
    for(int i=1;i<n-1;i++)ans+=s[i];
    ans/=n-2;
    OUT(ans);
  }
}

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

using namespace std;

int main()
{
    int n;
    while(cin >> n, n)
    {
        int max_s, min_s, sum;
        cin >> max_s >> min_s;
        sum = max_s + min_s;
        if(max_s<min_s) swap(max_s, min_s);
        for(int i=2; i<n; i++)
        {
            int s;
            cin >> s;
            sum += s;
            if(max_s<s) max_s = s;
            if(min_s>s) min_s = s;
        }
        cout << (sum - max_s - min_s) / (n - 2) << endl;
    }
}

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

int main()
{
	int in,a,maxer=0,miner=1000;
	int sum=0;
	int i=0;
	double ave=0.0;
	while( cin >> in,in ){
		for(i=0; i<in; i++){
			cin >> a;
			maxer=max(a,maxer);
			miner=min(a,miner);
			sum += a;
		}
		sum = sum - maxer - miner;
		ave = sum/(in-2);
		cout << floor(ave) << endl;
		sum = maxer = ave = 0;
		miner=1000;
	}
}

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

int main() {
    for(;;){
        int n;
        cin >> n;
        if (n==0) {
            break;
        }
        int a[n];
        for (int i=0; i<n;i++) {
            cin >> a[i];
        }
        sort(a,a+n);
        int ans=0;
        for (int i=1;i<n-1;i++) {
            ans+=a[i];
            }
        cout<<ans/(n-2)<<"\n";
        }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    
    cin.tie( 0 );
    ios::sync_with_stdio( false );
    
    while(true){
        int n;
        cin >> n;
        
        if(n == 0){ break; }
        vector<int> vc(n);
        
        for(int i=0; i<n; i++){
            cin >> vc[i];
        }
        auto mm = minmax_element(vc.begin(),vc.end());
        auto res = (accumulate(vc.begin(), vc.end(), 0)) - (*mm.first + *mm.second);
        cout << res / (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];
		maxnum=i;
		}
		if(score[i] < minscore){
		minscore = score[i];
		minnum=i;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore = lastscore +  score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

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

int N;

int getScore(int A[])
{
	int maxA, minA, lenA, total {};
	lenA = N - 2;
	maxA = *std::max_element(A, A + N);
	minA = *std::min_element(A, A + N);
	for (int i {}; i < N; ++i)
		total += A[i];
	total = total - minA - maxA;
	
	int score;
	score = total / lenA;
	return score;
}

int main()
{
	while (std::cin >> N && N > 0)
	{
		int a[N];
		for (int i {}; i < N; ++i)
			std::cin >> a[i];
		std::cout << getScore(a) << std::endl;
	}
}

C++: #include "bits/stdc++.h"

using namespace std;

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

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

int N, S;
int main() {
	while(cin >> N && N > 0) {
		int sum = 0;
		int largest = 0;
		int smallest = 1000;

		for(int i = 0; i < N; i++) {
			cin >> S;
			sum += S;
			if(S > largest) largest = S;
			if(S < smallest) smallest = S;
		}

		sum = sum - largest - smallest;
		cout << sum << endl;

	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
bool solve(){
  int inum;
  vector<int> idata;
  cin >> inum;
  if(!inum)return false;
  for(int i=0;i<inum;i++){
    int buf;
    cin >> buf;
    idata.push_back(buf);
  }
  idata.erase( max_element(idata.begin(), idata.end()));
  idata.erase( min_element(idata.begin(), idata.end()));
  int sum = accumulate( idata.begin(), idata.end(), 0 ) / idata.size();
  cout << sum << endl;
  return true;
}

int main(void){
  while(solve());
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<stack>
using namespace std;

int main(){
    int n;
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        int sum=0,max=0,min=1000,point;
        for(int i=1;i<=n;i++){
            scanf("%d",&point);
            if(point>max) max=point;
            if(point<min) min=point;
            sum+=point;
        }
        printf("%d\n",(sum-max-min)/(n-2));
    }
    return 0;
}

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

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