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>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>


using namespace std;

#define Max INT_MAX
#define Inf (INT_MAX/2)
#define Min INT_MIN


#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
// s <= x < g ?
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
// 0 <= x < w && 0 <= y < h ?
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

typedef pair<int, int> P;

int main()
{
    int n;
    while( cin >> n ){
        vector<int> vec;
        if( n == 0) {break;}
        rep(i,n){
            int tmp;
            cin >> tmp;
            vec.push_back(tmp);
        }
        sort(vec.begin(), vec.end());
        double sum = 0.0;
        for( int i = 1; i<vec.size() - 1; i++ ){
            //cout << "add" << i << endl;
            sum += double(vec[i]);
        }
        cout << floor(sum/double(vec.size()-2) ) << endl;
    }
    return 0;
}

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

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

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

using namespace std;

int main() {
    int n;

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

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

C++: #include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
	int n,sum=0;
	vector<int> v;
	for (;;) {
		cin >> n;
		if (n == 0)break;
		v.resize(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i];
		}
		sort(v.begin(), v.end());
		for (int i = 1; i < n - 1; i++) {
			sum += v[i];
		}

		cout << sum / (n - 2) << endl;
		sum = 0;
		
	}
}

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



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll n;
    while(cin>>n){
        if(n==0) break;
        ll ans = 0;
        ll a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
            ans += a[i];
        }
        ans -= *max_element(a,a+n) + *min_element(a,a+n);
        ans /= (n-2);
        cout << ans << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main()
{
  int n[20]={};
  int s[20][100]={};
  int answer[20]={};
  int MAX=-1,min=1001,jM=0,jm=0;
  int i=0,j=0;

  for(;;i++){
    cin >> n[i];//?????°??\???
    if(n[i]>=3&&n[i]<=100){
      for(MAX=-1,min=1001,j=0;j<n[i];j++){//?????°?¶??????????
	cin >> s[i][j];
	if(MAX<s[i][j]){//?????§????±???????
	  MAX=s[i][j];
	  jM=j;
	}
	if(min>s[i][j]){//????°??±???????
	  min=s[i][j];
	  jm=j;
	}
	answer[i]+=s[i][j];
      }
      
      answer[i]=(answer[i]-s[i][jM]-s[i][jm])/(n[i]-2);
    }else{
      break;
    }
  }
  for(i=0;n[i]>=3&&n[i]<=100;i++){//??????
    cout << answer[i] << endl;
  }
}

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

int main (){
	int n, i, max, min;
	int A[101];
	int sum;
	while (cin >> n && n > 0){
		sum = 0;
		for (i = 0; i < n; i++){
			cin >> A[i];
		}
		max = min = A[0];
		for (i = 0; i < n; i++){
			if (max < A[i]){
				max = A[i];
			}
			if (min > A[i]){
				min = A[i];
			}
			sum += A[i];
		}
		sum -= max;
		sum -= min;
		cout << sum / (n - 2) << endl;
	}

	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;


int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int ans=0,s[110];
		rep(i,0,n)cin>>s[i];
		sort(s,s+n);
		rep(i,1,n-1)ans+=s[i];
		print(ans/(n-2));
	}
	return 0;
}

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

class foo{
public:
  int icpc(int n){
    int ma=0, mi=1000, sum=0,s;
		for(int i=0;i<n;i++){
			cin >> s;
			ma=max(ma, s);
			mi=min(mi, s);
			sum+=s;
		}
		return (sum-ma-mi)/(n-2);
  }
  
  int main(){
    int n;
	  while(true){
  		cin >> n;
		  if(!n)return 0;
		  cout << icpc(n) << endl;
	  }
    return 0;
  }
};

int main(){return (new foo)->main();}

C++: #include <iostream>

int main() {
    using namespace std;

    int c;
    int num;
    int max ;
    int min;
    int sum;
    int ans;
    while(true){
        max = 0;
        min = 1001;
        sum = 0;
        cin >> c;
        if(c == 0){
            break;
        }
        for(int i = 0; i < c; i++){
            cin >> num;
            if(num > max){
                max = num;
            }
            if(num < min){
                min = num;
            }
            sum += num;
        }
        ans = (sum - max - min)/(c-2);
        cout << ans << "\n";
    }
    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;
    max = s;
    cin >> s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 0; i < n -2; i++){
      cin >> s;
      sum += s;
      if(max < s) max = s;
      if(min > s) min = s;
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<string>
#include<stdlib.h>

using namespace std;
#define rep(i,n) for(auto i=(n)*0;i<n;i++)
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cout << fixed << setprecision(30);
	int n;
	while (cin >> n, n){
		int top = 0, bottom = 1000,sum=0;
		rep(i, n){
			int s;
			cin >> s;
			sum += s;
			top = max(top, s);
			bottom = min(bottom, s);
		}
		cout << sum - top - bottom << endl;
	}
	return 0;
}