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 <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;
			if (largest < S) {
				largest = S;
			} if (smallest > S) {
				smallest = S;
			}
			sum += S;
		}
		cout << ((sum - largest - smallest) / (N - 2)) << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	while(true){
		int score;
		int n;
		int maxs,mins;
		vector<int> s(n);
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>s[i];
		}
		maxs=*max_element(s.begin(),s.end());
		mins=*min_element(s.begin(),s.end());
		for(int i=0;i<n;i++){
			score+=s[i];
		}
		cout<<(score-maxs-mins)/(n-2)<<endl;
	}
}

C++: #include <iostream>

using namespace std;

int main() {
  int n, s;
  while (true) {
    cin >> n;
    if (n == 0) break;
    int m = 1001, M = -1, sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      if (s < m) m = s;
      if (s > M) M = s;
      sum += s;
    }
    sum = sum - m - M;
    cout << sum / (n - 2) << endl;
  }
  
  return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main (){
  int N;

  while(cin >> N && N > 0){
    vector<int> score(N, 0);
    rep(i,N){
      cin >> score[i];
    }

    sort(ALL(score));

    int ave = accumulate(score.begin() + 1, score.end() - 1, 0)/ (N-2);

    cout << ave << endl;
  }

  return 0;
}

C++: #include <stdio.h>

int main(void) {
	int count;
	int point[200][2/*x,y*/];

	int n,d;

	while(1) {
		scanf( "%d", &count );
		if ( count == 0 ) { break; }
		
		int xmin,xmax,ymin,ymax;
		xmin=0, xmax=0, ymin=0, ymax=0;
		
		point[0][0]=0;
		point[0][1]=0;
		for ( int i=1; i<count; i++ ) {
			scanf("%d %d", &n, &d);

			switch ( d ) {
			case 0: //left
				point[i][0] = point[n][0]-1;
				point[i][1] = point[n][1];
				break;
			case 1: //down
				point[i][0] = point[n][0];
				point[i][1] = point[n][1]-1;
				break;
			case 2: //right
				point[i][0] = point[n][0]+1;
				point[i][1] = point[n][1];
				break;
			case 3: //up
				point[i][0] = point[n][0];
				point[i][1] = point[n][1]+1;
				break;
			}
			
			if ( xmax < point[i][0] ) { xmax = point[i][0]; }
			if ( xmin > point[i][0] ) { xmin = point[i][0]; }
			if ( ymax < point[i][1] ) { ymax = point[i][1]; }
			if ( ymin > point[i][1] ) { ymin = point[i][1]; }
		}
		
		printf("%d %d\n", xmax-xmin+1, ymax-ymin+1);
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n=3;
  int point[20], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) break;

    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }
    sort(point, point + n);
    for(int i = 1 ; i < n - 1 ; i++){
      average += point[i];
    }
    average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;


int main(){
	for(;;){
		int n;
		std::cin >> n;
		if(n==0){
			exit(0);
		}else{
			std::vector<int> a(n);
			rep(i,n)std::cin >> a[i];
			sort(all(a));
			std::cout << accumulate(a.begin()+1,a.end()-1,0)/(n-2) << std::endl;
		}
	}
}

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

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

	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>
long long int D[400000000];
long long int E[400000000];

using namespace std;
int main() {
	long long int N;
	long long int Y = -1;
	cin >> N;
	while (N) {
		Y++;
		for (long long int i = 0; i < N; i++) {
			cin >> D[i];
		}

		sort(D, D + N);
		long long int W = 0;
		for (long long int i = 1; i < N-1; i++) {
			W += D[i];
		}
		E[Y] = W / (N-2);
		cin >> N;
		
	}

	for (long long int i = 0; i <=Y ;i++) {
		cout << E[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
while(1){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
if(judge != 0){
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}else
break;
}
return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
        int n, s ;
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
  		for (int i=0; i<n; ++i){
			cin >> s;
			sum = sum + s;
			if (large < s) {large = s;}
			if (small > s) {small = s;}
		}
		int ans = 0;
		ans = (sum - large - small) / (n - 2);
		cout << ans << endl ;
	}
}

C++: #include<stdio.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                   
    j = right;                  

    pivot = x[(left + right) / 2];
    while (1) {                   

        while (x[i] < pivot)      
            i++;                  

        while (pivot < x[j])      
            j--;                  
        if (i >= j)               
            break;                

        Swap(x, i, j);            
        i++;                      
        j--;
    }

    if (left < i - 1)              
        QSort(x, left, i - 1);     
    if (j + 1 <  right)            
				QSort(x, j + 1, right);    
		}

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(void)
{
	int i;
	int j;
	int k;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	while(1){

		scanf("%d",&n);
		if(n==0) 
			break;
		
		j=0;
		for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		}

		QSort(p,0,n-1);	
	
		sum = 0;
		for(i=1;i<n-1;i++)
			sum += p[i];
	
			d[j] = sum / (n-2);
			j++;
	}
	
	for(k=0;k<j;k++){
		printf("%d",d[k]);
	}
	
	return 0;
}