Go: // ICPC 得点集計ソフトウェア
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; i++ {
			score_list = append(score_list, nextInt(sc))
		}

		// 最低点と最高点を取り除く (3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1:len(score_list)-1]

		// 平均点を求める
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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;
}

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

int main(){
    int N;
    vector<int> ans;

    while(cin>>N,N!=0){
        vector<int> point(N);
        for(int &i : point) cin>>i;

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

        int ave = 0;

        for(int i = 1; i < N-1;i++) ave += point[i];

        ans.push_back(ave/(N-2));
    }

    for(int i:ans) cout<<i<<endl;

}

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

int main() {
    int num, score, sum, max, min, i;
    while(1){
        cin >> num;
        if(!num)
            break;
        sum=0;
        max=0;
        min=10000;
        for(i=0; i<num; i++){
            cin >> score;
            if(score>max)max=score;
            if(score<min)min=score;
            sum+=score;
        }
        sum-=max;
        sum-=min;
        cout << sum/(num-2) << endl;
    }
    return 0;
}

C++: #include<iostream>

int mein() {

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

int main(){
    register int n,i;
    while(cin >> n,n){
		register int p;
        register int min = 1000;
        register int max = 0;
		register 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<bits/stdc++.h>
using namespace std;

// macro
using ll = long long;

// code starts
int main()
{
  int n;
  cin >> n;
  while(n != 0)
  {
    vector<int> s(n);
    for(int i=0;i<n;i++) cin >> s[i];
    sort(s.begin(), s.end());
    int sum = 0;
    for(int i=1;i<n-1;i++) sum += s[i];
    cout << sum/(n-2) << endl;
    cin >> n;
  }
}