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<stdio.h>

void sort(int p[],int n);

void sort(int p[],int n)
{
    int i,j,temp;

    for (i = 0; i < n - 1; i++) {
        for (j = n - 1; j > i; j--) {
            if (p[j-1] > p[j]) {
                temp = p[j];
                p[j] = p[j-1];
                p[j-1] = temp;
            }
        }	
    }
}

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

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

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

C++: #include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        int ma = 0;
        int mi = 1000;
        cin >> n;

        if(n == 0){
            break;
        }

        int a[n];

        for(int i=0;i<n;i++){
            cin >> a[i];
            if(ma < a[i]){
                ma = a[i];
            }
        }

        sort(a,a+n);

        for(int i = 2;i < n-1;i++){
            a[1] += a[i];
        }

        cout << a[1]/(n-2) << endl;
    }   
 
}

C++: #include<cstdio>

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n,i;
  while(true){
    int num[500],max=0,min=100000000,sum=0;
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&num[i]);
      if(num[i]<min)
	min=num[i];
      if(num[i]>max)
	max=num[i];
    }
    for(i=0;i<n;i++)
      sum+=num[i];
    sum=sum-max-min;
    printf("%d\n",sum/(n-2));
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int t[100];
	while(1){
		cin>>n;
		if(0==n){
			break;
		}
		for(int i=0;i<n;i++){
			cin>>t[i];
		}
		sort(t,t+n);
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=t[i];
		}
		cout<<sum/(n-2)<<endl; 
		
	}
}

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

int main(){
	int n;
	int j[110];
	int max,min;
	for(;cin>>n,n!=0;){
		for(int i=0;i<n;i++){
			cin>>j[i];
		}
		max=0;
		min=2000;
		int sum=0;
		for(int i=0;i<n;i++){
			if(max<j[i])max=j[i];
			if(min>j[i])min=j[i];
			sum+=j[i];
		}
		sum-=max+min;
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <iostream>
using namespace std;
int N, S;
int main() {
	while (cin >> N && N>0) {
		int sum = 0;
		int largest = 0;
		int smallest = 1001;
		for (int i=0; i<N; ++i) {
			cin >> S;
			largest = max(largest,S);
			smallest = min (smallest,S);
			sum += S;
		}
		sum = sum - largest;
		sum = sum - smallest;
		cout << sum /(N-2) << endl;
	}
	return 0;
}

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

int main() {

  while( true ) {
    long long int n, input;
    cin >> n;

    if ( n == 0 ) break;

    vector< long long int > s;

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

      cin >> input;
      s.push_back( input );

    }

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

    long long int ans = 0;

    for ( long long int i = 1; i < n - 1; i++ ) {

      ans += s[i];

    }

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

  }

  return 0;

}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

typedef vector<int> Ivec;
int main() {
	int n;
	
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			return 0;
		int Sum = 0, Max = -1, Min = 1001, num[2];
		for (int i = 0; n > i; i++) {
			int buf;
			scanf("%d", &buf);
			if (buf > Max) {
				Max = buf;
				num[0] = i;
			}
			if (buf < Min) {
				Min = buf;
				num[1] = i;
			}
			Sum += buf;
		}
		printf("%d\n", (int)((Sum - (num[0] == num[1] ? Max : Max+Min))/(n- (num[0] != num[1]) - 1)));
	}
	return 0;
}

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

int main()
{
	int N, n, sum, largest, smallest;
	
	while(cin >> N && N>0){
		sum  = 0; largest = 0; smallest = 1000;
		for(int i = 0; i<N; i++)
		{
			cin >> n;
			sum += n;
			
			if(smallest > n){ smallest = n;}
			if(largest < n){ largest = n;}
		}
	
		cout << (sum-smallest-largest)/(N-2) << endl;
	}
}

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

int main(){
    int n;
    while(cin >> n){
        vector<int> judges;
        for(int i=0; i<n; i++){
            int score;
            cin >> score;
            judges.push_back(score);
        }
        sort(judges.begin(), judges.end());
        judges.erase(judges.begin());
        judges.pop_back();

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n!=0){
    vector<int> point(n);
    for(int i=0;i<n;i++)
      cin>>point[i];
    sort(point.begin(),point.end());
    int ave=0;    
    for(int i=1;i<n-1;i++)
      ave+=point[i];
    ave/=(n-2);
    cout<<ave<<endl;
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int larger(int x,int y) {
	int z = 0;
	if (x > y)z = x;
	else z = y;
	return z;
}
int smaller(int x, int y) {
	int z = 0;
	if (x < y)z = x;
	else z = y;
	return z;
}
int main(void) {
	int s = 1;
	while (s == 1) {
		int sinsa, a[100], sum = 0, ave;
		cin >> sinsa;
		if (sinsa == 0)s = 2;
		for (int i = 0; i < sinsa; i++) {
			cin >> a[i];
		}
		int n = a[0];
		for (int i = 0; i < sinsa; i++) {
			n = larger(n, a[i]);
		}
		int m = a[0];
		for (int i = 0; i < sinsa; i++) {
			m = smaller(m, a[i]);
		}
		for (int i = 0; i < sinsa; i++) {
			sum += a[i];
		}
		sum = sum - n - m;
		ave = sum / (sinsa - 2);
		cout << ave<<endl;
	}

	return 0;

}

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

using namespace std;

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

C++: #include <iostream>

using namespace std;

int main(void)
{

	int num;
	int ave;
	
	while (cin >> num && num != 0 )
	{
		int a[num];
		int sum = 0, max = 0, min = 1000;
		for(int i = 0;i < num; i++)
		{
			cin >> a[i];
			sum += a[i];
			if(a[i] <= min)
				min = a[i];
			if(a[i] >= max)
				max = a[i];
		}
		ave = (sum - max - min) / (num - 2);
		cout << ave << endl;
	}

	return 0;
}