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>

int main(){
  int i, n, s;

  while (1) {
    scanf("%d", &n);
    if (n==0) {
      break;
    }
    int ans = 0, maxv = 0, minv = 1000;
    int score[n];
    for (i = 0; i < n; i++) {
      scanf("%d", &s);
      if (s > maxv) {
        maxv = s;
      }
      if (s < minv) {
        minv = s;
      }
      score[i] = s;
    }

    for (i = 0; i < n; i++) {
      ans += score[i];
    }

    printf("%d\n", (ans-maxv-minv)/(n-2));
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main{
  int a[2020];
  int i = 0;
  while (cin >> x){
    a[i++] = x;
  }
  saiten(a,0);
}
int saiten(a,j){
  int max = 0 , min = 0 , ave = 0;
  if (a[j] != 0){
    for (int k = j+1; k <= j+a[j]; k++;){
      if (max < a[k])
	max = a[k];
      if (min > a[k])
	min = a[k];
      ave += a[k];
    }
    ave = (ave - max - min)/(a[j]-2);
    cout << ave < endl;
    saiten(a, j+a[j]+1);
  }
}

C++: #include<iostream>
using namespace std;
int N, S;
int main(){
  while(cin >> N && N>0){
    int sum = 0;
    int min = 1001;
    int max = -1;
    for(int i=0;i<N;++i){
      cin >> S;
      sum += S;
      if(min>S) min = S;
      if(max<S) max = S;
    }
    int ans = (sum-max-min)/(N-2);
    cout << ans << endl;
  }
}

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

int main() {
	int a,b,c;
	vector<int> d;
	while(1){
		d.clear();
		c = 0;
		cin >> a;
		if(a == 0)break;
		for(int i = 0;i < a;i++){
			cin >> b;
			d.push_back(b);
		}
		sort(d.begin(),d.end());
		for(int i = 1;i < d.size()-1;i++){
			c+=d[i];
		}
		cout << c/(d.size() - 2) <<endl;
	}	
	return 0;
}

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

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n;

	while(cin >> n, n) {
		vi score(n);
		int min=1000000, max=0, sum=0;

		REP(i, n) {
			cin >> score[i];
			if(score[i] < min) {
				min = score[i];
			}
			if(score[i] > max) {
				max = score[i];
			}
			sum += score[i];
		}

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

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

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

}

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

int main() {
	int n;//3<=n<=100
	int s;//0<=s<=1000
	int max,min,total,result;
	int i,finish=0;
	
	scanf("%d",&n);
	
	while(finish==0){
	max=0;
	min=1000;
	total=0;
	for(i=0;i<n;i++){
		scanf("%d",&s);
		if(s<min){min=s;}
		if(s>max){max=s;}
		total+=s;
	}
	result=(total-min-max)/(n-2);
	printf("%d\n",result);
	
	scanf("%d",&n);
	if(n==0){finish=1;}
	}
	return 0;
}

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

int main(void){
	int n,m,max,min,answer;
	while(1){
		cin >> n;
		max = 0;
		min = INT_MAX;
		answer = 0;
		if (!n) break;
		for (int i=0;i< n;i++){
			cin >> m;
			if (m > max) max = m;
			if (m < min) min = m;
			answer += m;

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

	}

	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  while(true){
    int n;
    scanf("%d",&n);
    if(n==0)break;
    vi a(n);
    REP(i,n)scanf("%d",&a[i]);
    sort(ALL(a));
    int sum = 0;
    FOR(i,1,n-1)sum += a[i];
    sum /= (n-2);
    printf("%d\n",sum);
  }
  return 0;
}

C++: #include <bits/stdc++.h>

int main() {

  long N;
  std::vector<long> v;
  long temp;
  long ans;
  long total;

  for(;;) {
    v.clear();
    std::cin >> N;
    if( N == 0 ) break;

    for(int i = 0; i < N; ++i) {
      std::cin >> temp;
      v.push_back(temp);
    }

    std::sort(std::begin(v), std::end(v));

    total = 0;
    for(int i = 1; i < N-1; ++i) total += v[i];
    ans = total / (N-2);

    std::cout << ans << std::endl;
  }
  
  return 0;
}

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

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0)
      break;

    vector<int> p(n);
    int nmax = -1, nmin = 1001;
    int imax, imin;
    for(int i=0; i<n; i++){
      cin >> p[i];
      if(p[i] > nmax){
	nmax = p[i];
	imax = i;
      }
      if(p[i] < nmin){
	nmin = p[i];
	imin = i;
      }
    }

    int ave = 0;
    for(int i=0; i<n; i++){
      if(i != imax && i != imin)
	ave += p[i];
    }
    ave /= n-2;

    cout << ave << endl;
  }
  
  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=1001;
       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];
            }
           S=S+x[i];            
       }
       cout<<(S-(max+min))/(n-2)<<endl;
   }
   return 0;
}