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 <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

int a[1001];
int main(){
	int n, sum;
	while(cin >> n, n){
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> a[i];
			sum += a[i];
		}
		sum -= *max_element(a, a+n);
		sum -= *min_element(a, a+n);
		cout << sum/(n-2) << endl;
	}
	return 0;
}

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

int solve() {
    int N;
    cin >> N;
    if(N==0) return 0;
    vector<int> datas;
    datas.resize(N);
    for(int i=0; i<N; i++) {
        cin >> datas[i];
    }
    sort(datas.begin(), datas.end());
    int sum = 0;
    int counter = 0;
    for(auto itr=datas.begin()+1; itr!=datas.end()-1; itr++) {
        sum += *itr; counter++;
    }
    cout << sum/counter << endl;
    return 1;
}

int main() {
    while(solve()) {}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
  while(true){
    int n;
    vector<int> a;
    cin >> n;
    rep(i,n){
      int b;
      cin >> b;
      a.push_back(b);
    }
    sort(a.begin(),a.end());
    int total=0;
    repi(i,1,n-1){
      total+=a[i];
    }
    cout << total/(n-2) << endl;;
  }
  return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
//#include<>
using namespace std;

typedef long long int64;
typedef int int32;
typedef char int8;

#define rep(i,j) for(int i=0;i<j;i++)
#define repeat(i,j,k) for(i=(j),i<(k);i++)
#define repeat_eq(i,j,k) for(i=(j),i<=(k);i++)
#define rev_rep(i,j,k) for(i=(j)-1;i>=k;i--)
#define all(v) (v).begin(),(v).end()

const int INF=1<<30;//=10E10

int main()
{
  while(true){
      int n;cin>>n;
      if(n==0)break;
      vector<int> v;
      rep(i,n){
	int t;cin>>t;
	v.push_back(t);
      }
      sort(all(v));
      int ans=0;
      for(int i=1;i<v.size()-1;i++)
	ans+=v[i];
      cout<<ans/(v.size()-2)<<endl;
  }
  return 0;
}

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

using namespace std;

int main(){
  int n;
  vector<int> s;

  cin>>n;
  while(n!=0){
    s.resize(n);

    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    sort(s.begin(),s.end());
    s.erase(s.begin());
    s.erase(s.end()-1);

    int ans = 0;

    for(int i=0;i<n-2;i++){
      ans += s[i];
    }

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

    cin>>n;
  }
  return 0;
}

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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main() {
	int n;

	while( 1 ) {
		cin >> n;
		if( n == 0 ) break;
		vector<int> s( n );
		int sum = 0;
		REP( i, n ) {
			cin >> s[i];
			sum += s[i];
		}
		sort( ALL( s ) );
		sum -= s[0];
		sum -= s[n - 1];

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

}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
#include<cmath>
typedef long long int ll;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(i) i.begin(),i.end()

using namespace std;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0)break;
		vector<int> p;
		rep(i,n){
			int tmp;
			cin>>tmp;
			p.push_back(tmp);
		}
		sort(all(p));
		ll sum=0;
		for(int i=1;i<n-1;i++){
			sum+=p[i];
		}
		cout<<sum/(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);
        }
        
        sort( ALL(s) );
        
        for(i=0;i<s.size()-1;i++)
            ans+= s[i];
        
        ans = (ans- s[0]) / (i-1);
        
        cout << ans << endl;
        ans=0;
    }
    
    return 0;
}

C++: #include<iostream>

using namespace std;

int main() {
	double ave;
	int ans,a,b, n,max,min;
	while (1) {
		ave = 0;
		cin >> n;
		b = 0;
		if (n == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> a;
			if (b == 0) {
				max = a;
				min = a;
			}
			else {
				if (a > max)max = a;
				if (a < min)min = a;
			}
			ave += a;
			b = 1;
		}
		ans = (ave - max - min) / (n - 2);
		cout << ans << 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 0;
}

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


int main() {
    int n;
    while (cin >> n && n>0) {
       int sum,L,M,s;
       L = 0;
       M = 1000;
       sum = 0;
       for (int i=0;i<n;i++) {
            cin >> s;
            if (s>L) L=s;
            if (s<M) M=s;
            sum += s; 
       }
       sum -= L+M;
       sum /= n-2;
       cout << sum << endl;  
       }
}

C++: #include<stdio.h>
int main(){
  int a,ten[100],i,max=0,min=1000,sum=0,ave=0;

  while(1){
    max=0;
    min=1000;
    sum=0;
    ave=0;
    scanf("%d",&a);
    if(a==0)break;
    else{
      for(i=0;i<a;i++){
	scanf("%d",&ten[i]);
      }
      for(i=0;i<a;i++){
	if(max<ten[i]){
	  max=ten[i];
	}
      }
      for(i=0;i<a;i++){
	if(min>ten[i]){
	  min=ten[i];
	}
      }
      
      for(i=0;i<a;i++){
	sum+=ten[i];
      }
      ave=(sum-max-min)/(a-2);
      printf("%d\n",ave);
    }
  }


return 0;
}