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>
using namespace std;
int main(){
int judge;
int maxscore;
int minscore;
int maxnum;
int minnum;
cin >> judge;
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		i=maxnum;
		}
		if(score[i] < minscore){
		minscore = score[i];
		i = minnum;
		}
	}
score[maxnum] = 0;
score[minnum] = 0;
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore += score[j];
}
lastscore = lastscore/(judge - 2);
cout << lastscore <<endl;
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n=1,t;
    while(cin>>n,n){
        int num=0,count=0;
        vector<int> v;
        for(int i=0;i<n;i++){
            cin >>t;
            count++;
            v.push_back(t);
            num+=t;
        }
        num -= *max_element(v.begin(),v.end());
        num -= *min_element(v.begin(),v.end());
        int ans=(double)num/(count-2);
        cout<<ans<<endl; 
    }
}

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

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

	while (true) {
		cin >> n;
		sum = 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>
#include <algorithm>
using namespace std;

int main() {
  for (int j = 0;j < 20; j++ ){
    int n; cin >> n;
    if (n == 0) {
      break;
    }
    int s[n]; for (int i = 0; i < n; i++) cin >> s[i];

    sort(s, s+n);int t = 0;
    for (int i = 1; i < n - 1; i++) {
      t += s[i]; 
    }
    cout << t / (n - 2) << endl;
  }
   return 0;
}

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

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    while (1) {
        int N;
        cin >> N;
        if(N==0)
            break;
        int mi = INF, ma = 0, ans = 0;
        rep(i, N) {
            int in;
            cin >> in;
            ans += in;
            mi = min(mi, in);
            ma = max(ma, in);
        }
        cout << (ans - mi - ma) / (N - 2) << "\n";
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n,i;
		cout << "test";
    while(cin >> n,n){
		int p;
        int min = 1000;
        int max = 0;
		int total = 0;
		for(int i=0;i<n;i++){
			cin >> p;
			if(p > max) max = p;
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[20], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n == 0) break;

    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }
    sort(point, point + n);
      for(int i = 1 ; i < n - 1 ; i++){
	average += point[i];
    }
    average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int n, input;

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

    vector<int> scores;
    for (int i = 0; i < n; i++) {
      cin >> input;
      scores.push_back(input);
    }

    cout << (accumulate(scores.begin(), scores.end(), 0) - *max_element(scores.begin(), scores.end()) - *min_element(scores.begin(), scores.end())) / (n - 2) << endl;
  }

  return 0;
}

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

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

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

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

	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int n,i,p,max,min,s;

    while(1){
      cin>> n;
      if(n){}else break;
      
      cin>> p;
      s = p;
      max = p;
      min = p;

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

C++: #include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
int main(void){
    int n,ans=0;
    while(cin>>n,n){
        vi s(n);
        rep(i,n) cin>>s[i];
        sort(all(s));
        cout<<floor(accumulate(s.begin()+1,s.end()-1,0)/(n-2))<<endl;
    }
}

C++: #include<iostream>

using namespace std;

int main () {

  while (true){

    int n;
    int i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0)
      break;
??????
??????int point[100];

    for (i=0,i<n,i++){
      cin >> point[i];

      if (point[i] < mi)
        mi << point[i];

      if (point[i] > ma)
        ma << point[i];

      s += point[i];
    }

    cout << (s - mi - ma) / (n-2) << endl
  }
  return 0;
}

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

using namespace std;

struct CONTEST_DATA{
	int judgements;
	vector< int > points;
};

int main( void ){

	vector< CONTEST_DATA > contests;
	vector< int > answers;

	while( true ){
		CONTEST_DATA cd;
		cin >> cd.judgements;
		if( cd.judgements == 0 ){
			break;
		}
		int point;
		for( int i = 0; i < cd.judgements; i++ ){
			cin >> point;
			cd.points.push_back( point );
		}
		contests.push_back( cd );
	}

	for( int i = 0; i < contests.size(); ++i ){
		sort( contests[ i ].points.begin(), contests[ i ].points.end() );
	}
	for( int i = 0; i < contests.size(); ++i ){
		vector< int >::iterator p = contests[i].points.begin();
		contests[ i ].points.erase( p );
		p = contests[ i ].points.end() - 1;
		contests[ i ].points.erase( p );
	}

	for( int i = 0; i < contests.size(); ++i ){
		int answer = 0;
		for( int l = 0; l < contests[ i ].points.size(); ++l ){
			answer += contests[ i ].points[ l ];
		}
		cout << answer / ( contests[ i ].judgements - 2 )<< endl;
	}

	return 0;
}