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>
using namespace std;

int main() {

    while(true){

        int n;

        cin >> n;

        if(n == 0){
            break;
        }

        int ma=-1,mi=1001,sums=0;

        for(int i=0; i<n; i++){
            int input;
            cin >> input;
            sums += input;
            if(ma < input){
                ma = input;
            }
            if(mi > input){
                mi = input;
            }
        }

        sums -= ma + mi;
        cout << sums/ (n-2) << endl;

    }

    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n1;
	cin >> n1;
		int a[100000] = { 0 };
		for (int i = 0; i < n1; i++){
			cin >> a[i];
		}
		sort(a, a + n1);
		a[0] = { 0 };
		a[n1 - 1] = { 0 };
		for (int i2 = 1; i2 < n1; i2++){
			a[0] += a[i2];
		}
		cout << a[0] / (n1 - 2) << endl;
		return n1;
		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;
    sum += s;
    max = s;
    cin >> s;
    sum += s;
    if(max < s){
      max = s;
    }else{
      min = s;
    }
    for(int i = 2; i < n; i++){
      cin >> s;
      sum += s;
      if(max < s){
	max = s;
      }else if(min > s){
	min = s;
      }
    }
    sum -= max;
    sum -= min;
    int ave = sum / (n-2);

    cout << ave ;
  }

  return 0;
}

C++: #include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
    int n;
   int x[21];
   while(1){
       int max=-1,min=10001;
       int S=0;
       cin>>n;
       if(n==0){
           break;
       }
       for(int i=0;i<n;i++){
            cin>>x[i];
            if(min>x[i]){
                min=x[i];
            }
            if(max<x[i]){
                max=x[i];
            }
       }
       for(int i=0;i<n;i++){
           S=S+x[i];
       }
       S=S-(max+min);
       int A=0;
       A=S/(n-2);
       cout<<A<<endl;

   }
   return 0;

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

int main(){
	int n;
	while(cin >> n,n){
		int s[100],min = 1000,max = 0,sum = 0;
		for(int i = 0; i < n; i++){
			cin >> s[i];
			sum += s[i];
			if(s[i] < min){
				min = s[i];
			}
			if(s[i] > max){
				max = s[i];
			}
		}
		sum -= min + max;
		cout << floor(double(sum/(n-2))) << endl;
	}
	return 0;
}

C++: #include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define MP make_pair
#define PB push_back
#define REP(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long LL;
typedef vector<int> VI;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int n;
	VI ans;

	while(1){
		int n;
		int sum = 0,cnt = 0;
		cin >> n;
		if(n == 0) break;
		VI s(n);
		
		for(int i = 0;i < n;i++){
			cin >> s[i];
		}

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

		for(int i = 1;i < s.size() - 1;i++){
			sum += s[i];
			cnt++;
		}

		ans.PB(sum / cnt);
	}

	for(int i = 0;i < ans.size();i++)
		cout << ans[i] << endl;;

	return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
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 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);

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  for(;;){
	int N; cin >> N;
	if(!N) break;
	VI a(N);
	REP(i,N) cin >> a[i];
	SORT(a);
	cout << accumulate(a.begin()+1, a.end()-1, 0) / (N - 2) << endl;
  }
  return 0;
}

C++: 
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int n;					//審判の人数
		int ans = 0, max, min, temp;
		vector<int> points;		//点数を取得する

		cin >> n;	//以降のループ回数を取得する
		if( n == 0 ) break;	//ループ終了処理
		
		//点数を取得する
		for(int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			points.push_back(tmp);
			ans += tmp;
		}

		//最大値を取得する
		temp = -1;
		for(int i = 0; i < n; i++) 
			if(temp < points.at(i)) temp = points.at(i);
		max = temp;
		//最小値を取得する
		for(int i = 0; i < n; i++)
			if(temp > points.at(i)) temp = points.at(i);
		min = temp;

		//答えから最大値・最小値を一つづつ除く
		ans -= (max + min);
		//平均を取得する
		ans /= (n - 2);


		//出力
		cout << ans << endl;
	}

	//while(1){}
	return 0;
}

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

int main(){
  int n,s[100],num=0,max=s[0],min=s[0];
  
  cin>>n;

  while(n != 0);{
  
  for(int i=0;i<n;i++){
    cin>>s[i];

    if(max<s[i])max=s[i];
    if(max>s[i])min=s[i];
       
    num += s[i];
  }
  num = (num-max-min)/n;
    cout<<num<<endl;

  }
  return 0;
}

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;

vector<string> M;

int main(){

    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        
        vector<int> a(n);
        REP(i,n)cin>>a[i];
        sort(a.begin(),a.end());
        
        int ans=0;
        for(int i=1;i<n-1;i++){
            ans+=a[i];
        }
        
        cout<<ans/(n-2)<<endl;
        
    }
    
    return 0;
}