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++: using namespace std;
int main(){
	int n,t;
	while(cin>>n,n){
		int mx=0,mn=1000,s=0;
		for(int i=0;i<n;i++){
			cin>>t,s+=t;
			if(t>mx)mx=t;
			if(t<mn)mn=t;
		}
		cout<<(s-mx-mn)/(n-2)<<endl;
	}
	return 0;
}

C++: 
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <iomanip>
#include <functional>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(int argc, char* argv[])
{
			int ninzu=0;
	while(cin >> ninzu){
		int ans=0;
		int i=0;
		int temp=0;
		int a=0;

		vector <int>  s;

		
		for(i=0;i<ninzu;i++){
			cin >> a;
			if(temp < a){
				temp = a;
			}
			s.push_back(a);
			if(a == 0)break;
		}

		sort( ALL(s) );

		for(i=1;i<s.size()-1;i++){
			if(s[i] != temp || s[i] != 0)ans+= s[i];
		}

		ans = ans / (i-1);

		cout << ans << endl;
		ans=0;
	}

    return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int sum = 0, max = 0, small = 2 << 20;
        int point;
        rep(i,n){
            cin >> point;
            sum+= point;
            if(max < point) max = point;
            if(small > point) small = point;
        }
        cout << (sum - (max + small) ) / (n - 2) << endl;
    }
}

C++: # encodign: utf-8

while true do
    # ????°??????§???????????? (?????????0??\???1000??\???)
    max = -1
    min = 1001
    # ????¨?????????????
    sum = 0
    # n??????
    n = gets.to_i
    break if n == 0 # 0?????¨????????????
    # n?????????????????????
    n.times do
        v = gets.to_i
        min = v if v < min
        max = v if v > max
        sum += v
    end
    sum -= (min + max)
    p sum / (n-2)
end

C++: #include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0) break;
    int sum = 0,average = 0;
    vector<long long> x(n);
    rep(i,n) cin >> x.at(i);
    sort(x.begin(),x.end());
    for(int i = 1; i < n-1; i++){
      sum +=x.at(i);
    }
    average = sum /(n-2);
    cout << average << endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define prime first
#define weight second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		map<int, int> ev;
		int max = 0, min = 1000;
		rep(i, n){
			int s = 0;
			cin >> s;

			if(s > max) max = s;
			else if(s < min) min = s;

			if(ev.find(s) != ev.end()) ev[s]++;
			else ev[s] = 1;
		}

		ev[max]--;
		ev[min]--;

		int result = 0, factor = 0;
		for(map<int, int>::iterator it = ev.begin(); it != ev.end(); it++){
			for(int i = 0; i < it->second; i++){
				result += it->first;
				factor++;
			}
		}

		cout << result / factor << endl;
	}
	

	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int a[10000];
        for(int i = 0;i < n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        int sum = 0;
        for(int i = 1;i < n-1;i++){
            sum += a[i];
        }
        sum /= n-2;
        cout<<sum<<endl;
    }
    return 0;
}

C++: #include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int a,n;
  int sm,mx,mn;
  while(cin>>n&&n){
    sm=0;
    mx=0;
    mn=1000;
    for(i=0;i<n;i++){
      cin>>a;
      sm+=a;
      if(mx<a)
	mx=a;
      if(mn>a)
	mn=a;
    }
    cout<<(sm-mn-mx)/(n-2)<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
 
int main(){
    int n,i;
	//cout<< "1000*100 = " << 1000*100 << "\n" << "int_max = " << INT_MAX << "\n";
    while(cin >> n,n){
        int point[100]={0,};
        int min = 1000;
        int max = 0;
		int total = 0;
        //if(!n) break;
        for(i=0;i<n;i++){
            cin >> point[i];
            if(point[i] > max) max = point[i];
            if(point[i] < min) min = point[i];
			total += point[i];
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

C++: #include <iostream>
using namespace std;
int N, S;

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 1001; //min????°?????????¨?????????
    int max = -1;
    int average = -1;

    for (int i = 0; i < N; i++){
      cin >> S;
      sum += S;
      if( S > max ) max = S;
      if(S < min) min = S; 
    }

    average = sum - min - max / N - 2; //???N-2?????§???????????¨?????¨??????

    cout << sum << endl;
  }

  return 0;
}

C++: # include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

  while (cin >> n) {
    if (n == 0) return 0;

    vector<int> scr(n);
    for (int i=0; i<n; i++) {
      cin >> scr[i];
    }

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

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