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>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

int main()
{
    int n, p;
    while(cin >> n && n)
    {
        vector<int> points;
        int ans = 0;

        REP(n)
        {
            cin >> p;
            points.push_back(p);
        }

        sort(points.begin(), points.end());
        
        for(int i= 1; i < n -1;i++) ans += points[i];

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

    return 0;
}

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

int N;
int S;

int main(){
  while( cin >> N ){
    if( !N ) break;
    int nmax = -1000;
    int nmin  = 2000;
    int sum = 0;
    for(int i=0;i<N;i++){
      cin >> S;
      nmax = max( nmax, S );
      nmin = min( nmin,S );
      sum += S;
    }
    sum -= nmax + nmin;
    cout << sum/(N-2) << endl;
  }
}

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

int main() {
    std::vector<int> vec;
    while (true) {
        vec.clear();

        int n;
        std::cin >> n;

        if (n == 0)
            break;
        
        vec.resize(n);
        for (auto&& e : vec)
            std::cin >> e;
        
        std::sort(vec.begin(), vec.end());
        std::cout << std::accumulate(vec.begin() + 1, vec.end() - 1, 0) / (n - 2) << std::endl;
    }
}

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

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

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

using namespace std;

int main(){
  int N;;
  while(1){
    cin >> N;
    if(N == 0){
      break;
    }else{
      int array[N], ave, sum = 0;
      
      for(int i = 0;i < N;i++){
	cin >>array[i];
      }
      sort(array,array+N);
      for(int i = 0;i < N;i++){
	if(!(i == 0 || i == N-1)){
	sum += array[i];
	}
      }
      ave = sum /( N -2);
      cout << ave << endl;
      
    }
  }
  
  return 0;
}

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

using namespace std;

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

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

int main()
{
  int n, s, count, max, min, sum, adv;
  while(cin >> n){
    if(n == 0){
      break;
    }
    min = 1001;
    max = -1;
    sum = 0;
    count = 0;
    while(count < n){ 
      count++;
      cin >> s;
      sum += s;
      if(s < min){
        min = s;
      }
      if(s > max){
        max = s;
      }
    }
    sum = sum - max - min;
    adv = sum / (n - 2);
    cout << adv << endl;
  }
  return 0;
}

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

using namespace std;

struct CONTEST_DATA{
	int judgements;
	vector< int > points;
};

int main( void ){

	vector< CONTEST_DATA > contests;
	vector< int > answers;

	while( true ){
		CONTEST_DATA cd;
		cin >> cd.judgements;
		if( cd.judgements == 0 ){
			break;
		}
		int point;
		for( int i = 0; i < cd.judgements; i++ ){
			cin >> point;
			cd.points.push_back( point );
		}
		contests.push_back( cd );
	}

	for( int i = 0; i < contests.size(); ++i ){
		sort( contests[ i ].points.begin(), contests[ i ].points.end() );
	}
	for( int i = 0; i < contests.size(); ++i ){
		auto p = contests[i].points.begin();
		contests[ i ].points.erase( p );
		p = contests[ i ].points.end() - 1;
		contests[ i ].points.erase( p );
	}

	for( int i = 0; i < contests.size(); ++i ){
		int answer = 0;
		for( int l = 0; l < contests[ i ].points.size(); ++l ){
			answer += contests[ i ].points[ l ];
		}
		cout << answer / ( contests[ i ].judgements - 2 )<< endl;
	}

	return 0;
}

C++: #include <iostream>

int main() {
	while (true) {
		int referee;
		std::cin >> referee;
		if (referee == 0) {
			break;
		}

		int max, min;
		std::cin >> max >> min;
		if (max < min) {
			std::swap(min, max);
		}
		int total = 0;
		for (int i = 2; i < referee; ++i) {
			int score;
			std::cin >> score;
			if (max < score) {
				total += max;
				max = score;
			} else if (min > score) {
				total += min;
				min = score;
			} else {
				total += score;
			}
		}
		std::cout << (total / (referee - 2)) << std::endl;
	}
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	vector<int>a;
	int n, k, t;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	while(true) {
		a.clear();
		scanf("%d", &n);
      if(n==0)return 0;
		f(i, n) {
			scanf("%d", &x);
			a.push_back(x);
		}
		sort(a.begin(), a.end());
      s=0;
		f(i, n-2) {
			s += a[i + 1];
		}
		ans = s / (n - 2);
		printf("%d\n", ans);
	}



	return 0;
}

C++: import java.util.Scanner;
public class Main{
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		for(int i=0;i>-1;i++){
			int num=sc.nextInt();
			if(num==0){
				break;
			}else{
			int ave=0;
			int max=0;
			int min=1000;
			int sum=0;
				int[] score =new int[num];
				//Input scores
				for(int j=0;j<num;j++){
					score[j]=sc.nextInt();
					if(score[j]>max){
						max=score[j];
					}else if(score[j]<min){
						min=score[j];
					}
					sum+=score[j];
					ave=(sum-max-min)/(num-2);
				}

					System.out.println(ave);
				}
		}
	}
}

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

int main()
{
  int n;
  int kazu=0,sum=0;
  int max,min;

  while(1)
    {
      cin >> n;

      if(n == 0)break;

      sum = 0;

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

	  if(i == 0)
	    {
	      max = kazu;
	      min = kazu;
	    }

	  if(max < kazu) max = kazu;

	  if(kazu < min) min = kazu;
	}
      sum = sum - max - min;

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

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

int main() {
int i,n,x,y,a[20],ans;
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		x = 0;
		y = 0;
		for(i=0;i<n;i++){
		if(a[x] < a[i])x = i;
		if(a[y] > a[i])y = i;
		}
		ans = 0;
		for(i=0;i<n;i++){
			if(i == x)continue;
			if(i == y)continue;
			ans += a[i];
		}
		ans = ans / (n-2);
		printf("%d\n",ans);
	}
	return 0;
}