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 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;
		
		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];
	
			j = 0;
			d[j] = sum / (n-2);
			j++;
	}
	
	for(k=0;k<j;k++){
		printf("%d",d[k]);
	}
	
	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 sinsa,a[100],sum=0,ave;
	cin >> sinsa;
	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;
	return 0;

}

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

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

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  int n;
  while(cin >> n, n!=0){
    vector<int> s;
    int input = 0;
    for(int i=0; i<n; i++){
      cin >> input;
      s.push_back(input);
    }
    sort(s.begin(), s.end());
    int sum = 0;
    for(int i=1;i<n-1;i++){
      sum += s[i];
    }
    cout << floor(sum/(n-2)) << endl;
    s.clear();
  }
  return 0;
}

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

using namespace std;

int main(){
  vector<vector<int>> s;
  int n[100]={};
  int ma[100]={};
  vector<int> mi(100,1000);
  int tmp,c = 0;
  for(int i=0;i<100;i++){
    cin >> n[i];
    if(!n[i])break;
    s.push_back(vector<int>());

    for(int j=0;j<n[i];j++){
      cin >> tmp;
      s[i].push_back(tmp);
      ma[i] = max(ma[i],tmp);
      mi[i] = min(mi[i],tmp);
    }
    c++;
  }
  int ans;
  for(int i=0;i<c;i++){
    ans = floor((accumulate(s[i].begin(),s[i].end(),0) - ma[i] - mi[i])/(s[i].size()-2));
    cout << ans << endl;
  }


  return 0;
}

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

#define FOR(i,l,n) for(int i=(l);i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX_JUDGE 100
using namespace std;

int main(){
  int n,score[MAX_JUDGE];
  while(cin>>n,n){
    REP(i,n)cin>>score[i];
    sort(score,score+n);
    int sum=0;
    FOR(i,1,n-1)sum+=score[i];
    cout << sum/(n-2);
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include<stdio.h>

int main(){

int n;
int P[102]={};
while(1){
scanf("%d",&n);if(n==0)break;
for(int i=0;i<n;i++)
scanf("%d",&P[i]);

int s=0;
for(int i=0;i<n;i++)
for(int j=n-1;j>i;j--)
if(P[j]>P[j-1]){int t=P[j];P[j]=P[j-1];P[j-1]=t;}

for(int i=0;i<n;i++)
if(i!=0&&i!=n-1)s+=P[i];

s=s/(n-2);
printf("%d\n",s);
}
return 0;
}

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

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

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

using namespace std;

int n;
int s[100]={};
int count = 0;
int dai,syou;
int ans[1000]={};
int judge = 0;

int main()
{
    while(1){
        scanf("%d",&n);
        if(n == 0){
            break;
        }
        dai = 0;
        syou = 1000;
        for(int i=0;i<n;i++){
            scanf("%d",&s[i]);
            if(dai <= s[i]){
                dai = s[i];
            }
            if(syou >= s[i]){
                syou = s[i];
            }
        }
        int dai_count = 0;
        int syou_count = 0;
        for(int i=0;i<n;i++){
            if(s[i]==dai && dai_count ==0){
                dai_count=1;
                
            }else if(s[i] == syou && syou_count ==0){
                syou_count = 1;
            }else{
                ans[judge] += s[i];
            }
        }
        ans[judge] = ans[judge] / (n-2);
        
        judge++;

    }
    for(int i=0;i<judge;i++){
        cout << ans[i] << endl;
    }

    
    return 0;
}

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

#define FOR(i,l,n) for(int i=(l);i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX_JUDGE 100
using namespace std;

int main(){
  int n,score[MAX_JUDGE];
  while(cin>>n,n){
    REP(i,n)cin>>score[i];
    sort(score,score+n);
    int sum = accumulate(score+1,score+n-2,0);
    cout << sum/(n-2) <<endl;
  }
  return 0;
}

C++: #include<stdio.h>
int main(void) {
	int n, s[100] = {0}, max, min,sum,count;
	while(1){
		sum = 0;
		count = 0;
		scanf("%d", &n);
		if (n== 0) break;
		for (int i = n; i > 0; i--) {
			scanf("%d", &s[i]);
			if (i == n) {
				max = s[i];
				min = s[i];
			}
			if (max < s[i]) max = s[i];
			if (min > s[i]) min = s[i];
			count++;
			sum += s[i];
		}
		sum = sum - (max + min);
		printf("%d\n", sum / (count - 2));
	}
	return 0;
}