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>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
//---------------------------------------------------------------------------//
int n,sum=0;
int a[10000];
int main(){
        cin>>n;
        for(int i=0; i<n; i++) {
                cin>>a[i];
        }

        sort(a,n);
        for(int i=1; i<n-1; i++) {
                sum+=a[i];
        }
        cout<<sum/(n-2)<<endl;
}

C++: #include <stdio.h>

int sumSB(int n,int s[]){

int i,re,min = s[0],max = s[0];

for(i = 0;i < n;i++){
	if(min > s[i]){
		min = s[i];
	}
	
	else if(max < s[i]){
		max = s[i];
	}
	
}

return(min + max);
}

int main(void){
	int n,i,sum = 0,score[128],ave;
	
	while(1){
		scanf("%d",&n);
		if(n == 0) break;
		
		for(i = 0;i < n;i++){
			scanf("%d",&score[i]);
			sum += score[i];
		}
		sum -= sumSB(n,score);
		
		ave = sum / (n - 2);
		
		printf("%d",ave);
	}	
		return 0;
}

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

int main() {
  int max = 0;
  int min = 100000000;
  int sum = 0;
  int num = 0;
  int judge = 0;
  while (true) {
    sum = 0;
    int judge = 0;
    cin >> num;
    judge = num;
    if (num == 0) break;
    for (int i = 0; i < judge; i++) {
      cin >> num;
      if (max < num) max = num;
      if (min > num) min = num;
      sum += num;
    }
    int result = (sum - max - min) / (judge - 2);
    cout << result << endl;
  }
  return 0;
}

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

int main(){
	int n1;
	cin >> n1;
	int a[100000] = { 0 };
	for (int i = 0; i < n1; i++){
		cin >> a[i];
	}
	sort(a, a + n1);
	a[0] = { 0 };
	a[n1 - 1] = { 0 };
	for (int i2 = 1; i2 < n1; i2++){
		a[0] += a[i2];
	}
	cout << a[0] / (n1 - 2) << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
int totalscore = 0;
cin >> judge;
if(judge != 0){
	int score;	
	for(int i=0; i<judge; i++){
	cin >> score;
		if(score[i] > maxscore){
		maxscore = score;
		}
		if(score[i] < minscore){
		minscore = score;
		}
		if(i==0){
		minscore = score;
		}
	totalscore += score;
	}

int lastscore = (totalscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n;
	int y[20] = { 0 };
	int max;
	int min;
	n = 1;
		int j = 0;
		while (n != 0){
			
			cin >> n;
			max = 0;
			min = 1000;
				y[j] = 0;
			for (int i = 0; i < n; i++){
				int x[1000] = { 0 };
				cin >> x[i];

				if (max < x[i]) max = x[i];
				if (min > x[i]) min = x[i];
				y[j] += x[i];
			}
			y[j] = y[j]-max - min;
			y[j] = y[j] / (n - 2);
			j++;
		}
	for (int k = 0; k < j; k++){
		cout << y[k]<< endl ;
	}
	return 0;
}

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

int main() {
	int n, max, min, s;
	long sum;

	while (true) {
		cin >> n;
		max = min = 0;
		if (n == 0)	break;

		for (int i = 0; i < n; i++) {
			cin >> s;
			if (s < min)	min = s;
			if (s > max)	max = s;
			sum += s;
		}
		sum -= (min + max);
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

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

int N, S;

int main(){
   while ( cin >> N && N>0){
      int M = -1, m = 1001 ,addup = 0;
      for ( i = 0; i<N; i++){
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   }
   cout << (addup - M - m)/(n-2)  << endl;
}

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

int main(void){
	int n;

	while(cin>>n, n){
		int sum = 0;
		int maxS = 0, minS = 1000;
		for(int i=0;i<n;i++){
			int x;
			cin>>x;
			sum += x;
			maxS = max(maxS,x);
			minS = min(minS,x);
		}
		cout<<(sum - maxS - minS) / (n - 2)<<endl;
	}
	return 0;
}

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

int main ()
{
	int n, s, adv,  a[100];
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
	const int MAXN = 100;
	int a[MAXN];

	for(int i = 0 ; i < n; i++){
		cin >> a[i];
	}
	int max = a[0], min = a[0], kei = 0;
	for(int i = 0 ; i < n ; i++){
		if(max < a[i]){
			max = a[i];
		}
		if(min > a[i]){
			min = a[i];
		}
		kei += a[i];
	}
	adv = (kei - max - min) / (n - 2);
	cout << adv << endl;
	}


	return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
/*
int i_max(int data[],int size){
	int m=d[0];
	for(int i=1;i<size;i++) if(m<d[i]) m=d[i];
	return m;
}
int i_min(){
	int m=d[0];
	for(int i=1;i<size;i++) if(m>d[i]) m=d[i];
	return m;
}*/

int i_max(int p,int q){
	if(p>q) return p;
	return q;
}
int i_min(int p,int q){
	if(p<q) return p;
	return q;
}

int main(){
	int data;
	int max,min;
	int p,n;
	while(cin>>n){
		if(n==0) break;
		data=0;
		max=0;
		min=10000;
		for(int i=0;i<n;i++){
			cin>>p;
			data+=p;
			max=i_max(max,p);
			min=i_min(min,p);
		}
		data-=(max+min);
		data/=(n-2);
		cout<<data<<endl;
	}
	return 0;
}

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

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

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

using namespace std;




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

C++: #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        vector<int> ar(n);
        for(int &x : ar){
            scanf("%d",&x);
        }
        sort(ar.begin(),ar.end());
        int sum=0;
        for(int i=1;i<n-1;i++){
            sum+=ar[i];
        }
        printf("%d\n",sum/(n-2));
    }
}

C++: #include <iostream>

using namespace std;

int main(){
    int n, max = 0, min = 10000, sum = 0, s[1000];
    while(cin >> n && n > 0){
        for (int i = 0; i < n; i++ ){
            cin >> s[i];
            sum += s[i];
        }
        for (int i = 0; i < n; i++){
            if (s[i] > max)
                max = s[i];
        }
        for (int i = 0; i < n; i++){
            if (s[i] < min)
                min = s[i];
        }
        cout << (sum - max - min)/(n - 2) << endl;
    }
}