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 <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int n;


	int s;

	int sum,ave;

	int i;

	while(1){
		vector<int> v;
		sum = 0;

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

		for(i=0;i<n;i++){
			cin >> s;
			v.push_back(s);
		}

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

		for(i=1;i<v.size()-1;i++){
			sum += v[i];
		}

		ave = sum/(v.size()-2);

		cout << ave << endl;

	}
	return 0;
}

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

int main(){
	int ninzuu;
	while(cin >> ninzuu && ninzuu != 0){
		int max_value=-1;
		int min_value=1001;
		int sum=0;
		int average;
		for(int i=0;i<ninzuu;i++){
			int tmpNum;
			cin >> tmpNum;
			max_value = max(tmpNum,max_value);
			min_value = min(tmpNum,min_value);
			sum += tmpNum;
		}
		sum -= (max_value + min_value);
		average = sum / (ninzuu - 2);
		cout << average << endl; // 出力
	}
}

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){
    if(n==0)break;
    REP(i,n)cin>>score[i];
    sort(score,score+n);
    int c=0;
    FOR(i,1,n-1)c+=score[i];
    cout << c/(n-2);
  }
  return 0;
}

C++: #include<iostream>
#define INF 1<<29
using namespace std;

int main(){
	int n;
	while(cin>>n && n){
		int ma=0,mi=INF;
		int sum=0;
		for(int i=0;i<n;i++){
			int s;
			cin>>s;
			mi=min(mi,s);
			ma=max(ma,s);
			sum+=s;
		}
		cout<<(sum-mi-ma)/(n-2)<<endl;
	}
}

C++: #include <iostream>

using namespace std;

int main( void )
{
	int n;
	while(cin >> n, n) {
		int Max = 0, Min = 1001, Sum = 0;
		int i=n;
		while(i--) {
			int s;
			cin >> s;
			Sum += s;
			if(Max < s) Max = s;
			if(Min > s) Min = s;
		}
		int ave = (Sum - Max - Min) / (n - 2);
		cout << ave << endl;

	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
        int n,sum=0,ans=0,max=0,min=1001;
        cin >> n;
        if(n==0) break;
        int s[n];
        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];
          if(s[i] < min) min =s[i];
        }
        sum = sum -max -min;
        ans = sum/(n-2);
        cout << ans << endl;
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {1,0,-1,0};

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		vector<int> score;
		for(int i=0;i<n;i++){
			int s;
			scanf("%d",&s);
			score.push_back(s);
		}

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

		int sum=0;
		for(int i=1;i<score.size()-1;i++){
			sum += score[i];
		}

		printf("%d\n",sum/(score.size()-2));
	}
}

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

int main(void){
  while(true){
    long n;
    cin >> n;
    if(n == 0){
      break;
    }
    vector<long> S;
    for(int i = 0; i < n;++i){
      long s;
      cin >> s;
      S.push_back(s);
    }
      long mx = *max_element(S.begin(), S.end());
      long mn = *min_element(S.begin(), S.end());
      long sum = accumulate(S.begin(), S.end(), 0);
      cout << (sum - mx - mn) / (n - 2)  << endl;
  }
 return 0;
}

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


int main()
{
	int n, s[101];
	while (cin >>n &&n> 0) {
		int mean = 0;
		for (int i = 0; i < n; i++) cin >> s[i];
		sort(s, s + n);
		for (int i = 1; i < n - 1; i++)mean += s[i];
		cout << mean << endl;
	}
    return 0;
}

C++: #include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
   int n;
   int x;
   while(1){
       int max=-1,min=1001;
       int S=0;
       cin>>n;
       if(n==0){
           break;
       }
       for(int i=0;i<n;i++){
            cin>>x;
            if(min>x){
                min=x;
            }
            if(max<x){
                max=x;
            }
           S=S+x;            
       }
       cout<<(S-(max+min))/(n-2)<<endl;
   }
   return 0;
}

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

int main() {

    while(true){

        int n;

        cin >> n;

        if(n == 0){
            break;
        }

        int ma=-1,mi=1001,sums=0;

        for(int i=0; i<n; i++){
            int input;
            cin >> input;
            sums += input;
            if(ma < input){
                ma = input;
            }
            if(mi > input){
                mi = input;
            }
        }

        sums -= ma + mi;
        cout << sums/ (n-2) << 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 n1;
		return 0;
}

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

int main(){
  int n, s, sum, max, min;
  while(1){
    cin >> n;
    if(n == 0) break;
    sum = 0;
    cin >> s;
    sum += s;
    max = s;
    cin >> s;
    sum += s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 2; i < n; i++){
      cin >> s;
      sum += s;
      if(max < s){
	max = s;
      }else if(min > s){
	min = s;
      }
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave ;
  }

  return 0;
}

C++: #include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
    int n;
   int x[21];
   while(1){
       int max=-1,min=10001;
       int S=0;
       cin>>n;
       if(n==0){
           break;
       }
       for(int i=0;i<n;i++){
            cin>>x[i];
            if(min>x[i]){
                min=x[i];
            }
            if(max<x[i]){
                max=x[i];
            }
       }
       for(int i=0;i<n;i++){
           S=S+x[i];
       }
       S=S-(max+min);
       int A=0;
       A=S/(n-2);
       cout<<A<<endl;

   }
   return 0;

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

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