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 <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int n;

  int tensu[200];

  while(cin>>n,n){
	cout << n << endl;//
  int max = 0;
  int min = 1000;
  int sum=0;
	REP(i,n){
	  cin >> tensu[n];
	  sum+=tensu[n];
	  if(max<tensu[n])
		max=tensu[n];
	  if(min>tensu[n])
		min=tensu[n];
	}

	//cout<<min<<endl<<max<<endl<<sum<<endl;//

	cout << (sum-max-min)/(n-2) << endl;

  }

}

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

int main() {
    int n; cin >> n;
    while (n != 0) {
        int max_s = 0, min_s = 1000, sum_s = 0;
        for (int i = 0; i < n; ++i) {
            int s; cin >> s;
            max_s = max(max_s, s);
            min_s = min(min_s, s);
            sum_s += s;
        }
        int ans = (sum_s - max_s - min_s) / (n - 2);
        cout << ans << endl;
        
        cin >> n;
    }
    return 0;
}

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

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

int main() {
	while (cin >> N && N>0) { // By while (), adopt the form of std in 
		int sum = 0;
		max = 0;
		min = 0;
		for (int i=0; i<N; i++) {
			cin >> S;
			sum += S; // calculate sum
			if (max < S) max = S; // search max
			if (min > S) min = S; // search min
		}
		int ans = (sum-max-min)/(N-2);
		cout << ans << endl;
	}
}

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

using namespace std;

const int MAX_N = 110;

int judge_num;
int score[MAX_N];

//---------------------//                                                                                            
int main()
{
        while (cin >> judge_num) {

                if (judge_num == 0) break;

                for(int i = 0; i < judge_num; ++i) {
                        cin >> score[i];
                }

                sort(score, score + judge_num);

                int ave;
                double sum_temp = 0;

                for (int i  = 1; i < judge_num - 1; ++i) {
                        sum_temp += score[i];
                }

                ave = (int)( floor( sum_temp / (judge_num - 2) ) );

                cout << ave << endl;
        }

        return 0;
}

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

int main() {
	int n,point,sum,ma,mi;
	
	while(cin>>n){
		if(n==0)break;
		sum=0;
		ma=0;
		mi=1000;
		for(int i=0;i<n;i++){
			cin>>point;
			sum+=point;
			if(ma<point)ma=point;
			if(mi>point)mi=point;
		}
		cout<<(sum-ma-mi)/(n-2)<<endl;;
			}
	
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int n){

  int a[1000000];

  rep(i,n){
    cin>>a[i];
  }
  sort(a,a+n);

  int ans=0;
  FOR(i,1,n-1){
    ans+=a[i];
  }

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


int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    f(n);
  }


  return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int sum=0,M=0,m=0;
    REP(i,n){
      int tmp;
      cin >> tmp;
      sum+=tmp;
      if(M<tmp) M=tmp;
      if(m>tmp) m=tmp;
    }
    cout << (sum-M-m)/(n-2) << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int n;
int data[100];


int solve() {
  int avg;
  sort(data, data+n);
  avg = 0;
  for(int i = 1; i < n-1; ++i) {
    avg += data[i];
  }
  return avg / (n-2);
}

main() {
  while(( cin >> n ) && n) {
    for(int i = 0; i < n; ++i) {
      cin >> data[i];
    }
    cout << solve() << endl;
  }
}

C++: #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int sum = 0, MAX = 0, MIN = 1100;
        rep(i, 0, n){
            int s;
            cin >> s;
            sum += s;
            MAX = max(MAX, s);
            MIN = min(MIN, s);
        }
        cout << (sum - MAX - MIN) / (n - 2) << endl;
    }
}