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 REP(i, n) for(int i = 0; i < n; i++)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(cin >> n){
        if(n == 0) break;
        vector<int> A(n);
        REP(i, n) cin >> A[i];
        sort(A.begin(), A.end());
        if(n - 2 <= 0){
            cout << 0 << endl;
            continue;
        }
        int total = 0;
        REP(i, n - 1){
            if(i) total += A[i];
        }
        cout << total / (n - 2) << endl;
    }

    return 0;
}

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

using namespace std;
int main() {
	int n;
	while (cin >> n && n) {
		int sum = 0;
		int ln = 100000;
		int hn = 0;
		for (int i = 0; i < n; ++i) {
			int d;
			cin >> d;
			ln = min(d, ln);
			hn = max(hn, d);
			sum += d;
		}
		cout << (sum - hn - ln) / (n - 2) << endl;
	}
	return 0;
}

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

int n;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(true){
		cin >> n;
		if(n == 0) return 0;
		vector<int> v;
		for(int i=0; i<n; ++i){
			int t;
			cin >> t;
			v.push_back(t);
		}
		int sum = 0;
		sort(v.begin(), v.end());
		for(int i=1; i<n-1; ++i)
			sum += v[i];
		sum /= n-2;
		cout << sum << "\n";
	}
}

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

int main()
{
    int x;
    while(1){
        cin >> x;
        if(x == 0) break;
        int max = -1, mini = 10000, sum = 0, score = 0, y = 0;
        for(int i = 0; i < x; i++){
           cin >> score;
          sum += score;
          if(score > max) max = score;
            if(score < mini) mini = score;
        }
        sum -= max + mini;
        y = sum / (n - 2);
        cout << y << endl;
    }
    return 0;
}

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

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 1001; //min????°?????????¨?????????
    int max = -1;
    int average = -1;

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

    average = (sum - min - max) / N - 2; //???N-2?????§???????????¨?????¨??????

    cout << average << endl;
  }

  return 0;
}

C++: import math
import copy

def average(points):
    sum = 0
    for i in points:
        sum += i
    return sum / len(points)

outputs = []

while True:
    num = int(input())
    if num == 0:
        break

    points = []
    for _ in range(num):
        point = int(input())
        points.append(point)

    points = sorted(points)
    points = points[1:len(points)-1]

    ave = average(points)
    outputs.append(int(ave))

for ave in outputs:
    print(ave)

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

int main(){
	int n;
	while(cin >>n){
		if(n == 0) break;
		vector<int> vec;
		int tmp, max, min;
		cin >>tmp;
		vec.push_back(tmp);
		max = tmp;
		min = tmp;
		bool maxb = true, minb = true;
		for(int i = 1; i < n; i++){
			cin >>tmp;
			vec.push_back(tmp);
			if(tmp < max) max = tmp;
			if(tmp > min) min = tmp;
		}
		int sum = 0;
		for(int i = 0; i < vec.size(); i++){
			if(vec[i] == max && maxb){
				maxb = false;
			} else if(vec[i] == min && minb){
			minb =false;
		} else{
			vec[i] += sum;
		}
		cout <<sum <<endl;
		return 0;
	}
}
}

C++: #include<algorithm>
#include<iostream>
#define rep(i,a) for(int i=0;i<(a);++i)

int n;

int main()
{
	while( std::cin >> n, n )
	{
		int ma = 0, mi = 1001, S = 0;
	
		rep( i, n )
		{
			int a;
			std::cin >> a;
			ma = std::max( ma, a );
			mi = std::min( mi, a );
			S += a;		
		}
		
		std::cout << (S-ma-mi)/n << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)


int main()
{
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n)
    {
        if(n == 0)
            return 0;
        vector<int> nums;
        REP(i, n)
        {
            int tmp;
            cin >> tmp;
            nums.push_back(tmp);
        }
        sort(nums.begin(),nums.end());
        int sum = 0;
        RFOR(i, n-1, 1)
            sum += nums[i];
        cout << sum / (n-2) << '\n';
    }
}

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

using namespace std;

int main(){
	int			n;
	int			s_buf;
	int			sum;
	vector<int>	s;

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

		sum = 0;
		s_buf = 0;
		s.clear();

		for(int i = 0; i < n; i++){
			cin >> s_buf;

			s.push_back(s_buf);
		}

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

		for(int i = 1; i < s.size() - 1; i++){
			sum += s[i];
		}

		cout << sum / (s.size() - 2) << endl;
	}
}

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

int main(void){

  int n;
  int s[1000];
  int max,min,sum,ave;

  while(1){

    max=0;
    min=1000;
    sum=0;
    ave=0;

    cin >> n;

    if( n == 0 ) break;

    for( int i = 0 ; i < n ; i++ ){

      cin >> s[i];

    }

    for( int i = 0 ; i < n ; i++ ){

      if( max < s[i] ) max = s[i];

      if( min > s[i] ) min = s[i];

      sum+= s[i];

    }

    sum = sum - max - min;
    ave = sum / (n-2);

    cout << ave << endl;

  }

  return 0;

}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(1){
		int a, max=-1, min=100000, sum=0, ans;
		cin >> n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin >> a;
			if(a<min) min=a;
			if(a>max) max=a;
			sum += a;
		}
		ans = (sum-(max+min))/(n-2);
		cout << ans << endl;
	}
}

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 <stdio.h>
#include <string.h>

int main(void){
	int i, j, point[1001], n, s, sum, cnt;
	scanf("%d",&n);
	while(n != 0){
		memset(point,0,sizeof(point));
		for(i = 0;i < n;i++){
			scanf("%d",&s);
			point[s]++;
		}
		for(i = 0;i <= 1000;i++){
			if(point[i]){
				point[i]--;
				break;
			}
		}
		for(i = 1000;i >= 0;i--){
			if(point[i]){
				point[i]--;
				break;
			}
		}
		sum = 0;
		cnt = 0;
		for(i = 0;i <= 1000;i++){
			for(j = 0;j < point[i];j++){
				sum += i;
				cnt++;
			}
		}
		printf("%d\n",sum / cnt);
		scanf("%d",&n);
	}
	return 0;
}