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<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main(){
	int i,j,k,l,m,n;
	while(cin>>n){
		if(n==0) break;
		int mx=0, mn=2000;
		k=0;
		rep(i,n){
			cin >> m;
			mx = max(mx,m);
			mn = min(mn,m);
			k+=m;
		}
		cout << (k-mx-mn)/(n-2) << endl;
	}
}

C++: #include <iostream>

int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int n;
	int score[1024];

	while (true) {
		std::cin >> n;
		if (!n) break;

		for (int i = 0; i < n; i++) std::cin >> score[i];

		qsort(score, n, sizeof(int), compare);
		double sum = 0;
		for (int i = 1; i < n - 1; i++) sum += score[i];
		int ave = int(sum / (n-2));
		std::cout << ave << '\n';
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    
    while(true){
        int n;
        int max_v = INT_MIN;
        int min_v = INT_MAX;
        int sum = 0;
        cin >> n;
        
        if( n == 0 )return 0;
        
        for(int i = 0 ; i < n ; i++ ){
            int temp;
            cin >> temp;
            sum += temp;
            max_v = max(max_v,temp);
            min_v = min(min_v,temp);
        }
        
        sum -= max_v;
        sum -= min_v;
        
        cout << sum / (n-2) << endl;
    }
    
    return 0;
}

C++: #include <stdio.h>
int main(void){
    int i, score, sum, max, min;
    double ave;
    int n=1;
    scanf("%d", &n);
    while(n!=0){
        ave=0; max=0; min=1000;
        for(i=0;i<n;i++){
            scanf("%d", &score);
            ave = (ave*i + score)/(i+1);
            if(score>max){
                max=score;
            }
            if(score<min){
                min=score;
            }
        }
        ave=(ave*i-min-max)/(i-2);
        printf("%d\n", (int)ave);
        scanf("%d", &n);
    }
    return 0;
}

C++: import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int sum=0,i,max=0,min=1000,ave;
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			for(i=0;i<n;i++){
				int point=sc.nextInt();
				if(point<min){
					min=point;
				}
				if(point>max){
					max=point;
				}
				sum=sum+point;
			}
			ave=(sum-max-min)/(n-2);
			System.out.println(ave);
		}
	}
}

C++: #include <cstdio>

using namespace std;

int main(){
  int min,max,sum,n,score;

  while(1){
    scanf=0("%d",&n);
    if(!n) break;

    max=0;min=10000;sum=0;

    for(int i=0;i<n;i++){
        scanf("%d",&score);
        if(max<score) max=score;
        if(min>score) min=score;
        sum+=score;
    }

    printf("%d",(score-max-min)/(n-2));

    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

	int n;
	int inp;
	int sum,max,min;

	while(1){

		cin>>n;
		if(n==0) break;

		cin>>inp;
		min=inp,max=inp,sum=inp;
		for(int i=1;i<n;i++){
			cin>>inp;
			sum+=inp;
			if(min>inp) min=inp;
			if(max<inp) max=inp;
		}
		cout<<(sum-min-max)/(n-2)<<endl;
	}

	return 0;
}

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

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int ans=0;
		int mini=1001;
		int maxi=0;
		for(int i = 0;i<n;i++){
			int a;
			cin>>a;
			ans+=a;
			mini=min(mini,a);
			maxi=max(maxi,a);
		}
		cout<<(ans-maxi-mini)/(n-2)<<endl;
	}
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	while(true){
		int n; cin>>n;
		if(n==0)break;
		vector<int>s(n); for(auto&&i:s)cin>>i;
		sort(s.begin(),s.end());
		cout<<accumulate(s.begin()+1,s.end()-1,0)/(n-2)<<"\n"s;
	}
}

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 / (n - 2)) <<endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

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

int main() {
	int c[20];   // int[] c = new int[20];
	int w = 0;
	while (true)
	{
		int a;
		cin >>  a;// int a = int.Parse(Console.ReadLine());
		if (a == 0)
			break;
		int sum = 0;
		int b[a];
		for (int j = 0; j < a; j++)
		{
			cin >> b[j];
			sum += b[j];
		}
		int maxi = 0,mini = 1000000000;
		for (int j = 0; j < a; j++) {
			if (maxi < b[j])
				maxi = b[j];
			if (mini > b[j])
				mini = b[j];
		}
		sum -= maxi + mini;
		c[w] = (sum / (a - 2));
		w++;
	}
	for (int j = 0; j<w; j++)
	{
		cout << c[j] << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <functional>
#include <stack>
#include <numeric>
#define PI 3.1415926535
#define FOR(i,n) for (int i=0; i<(n) ;i++)
#define INF 114514810

using namespace std;

int n, t, sum;
vector<int> s;

int main(){
	while (cin >> n){
		if (n == 0) break;
		FOR(i, n) {
			cin >> t;
			s.push_back(t);
		}
			sort(s.begin(), s.end());
		sum = accumulate(s.begin() + 1, s.end() - 1, 0);
		cout << sum / (n - 2) << endl;
		s.clear();
	}
}

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

C++: #include<cstdio>
#include<iostream>
#define S 100

int main(void)
{
	int a[S];
	int i;
	int n,max,min,sum=0;
	
	for(;;)
	{
		max=0, min=1000,sum=0;
		
		scanf("%d",&n);
		if(n==0) break;
		
		for(i=0; i<n; i++)
		{
			scanf("%d",&a[i]);
		}
		
		for(i=0; i<n; i++)
		{
			if(max<a[i]) max=a[i];
			if(min>a[i]) min=a[i];
		}
		
		for(i=0; i<n; i++)
		{
			sum+=a[i];
		}
		
		sum=sum-max-min;
		printf("%d\n",sum/(n-2));
	}
	
	return 0;
}