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>
using namespace std;
int main(){
    int n, i, p;
    while(cin >> n,n){
        int min = 1000;
        int max = 0;
		int total = 0;
		for(int i=0;i<n;i++){
			cin >> p;
			if(p > max) max = p;
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }
}

C++: #include<stdio.h>

int main(){
  int n,s;
  int maxm,mini,sum;
  
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    sum=0;
    maxm=0;
    mini=1000;
    for(int i=0;i < n;i++){
      scanf("%d",&s);
      sum=sum+s;
      if(maxm < s){
        maxm=s;
      }
      if(mini > s){
        mini=s;
      }
    }

    printf("%d\n", (sum-maxm-mini)/(n-2) );
  }
  return 0;
}

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

int main() {
    int scores[1000];
    int n;
    int min, max;
    int sum = 0;
    int minf = 0, maxf = 0;

    while(cin >> n) {
        if(n == 0) {
            break;
        }
        for(int i = 0; i < n; i++) {
            scanf("%d", &scores[i]);
            if(i == 0) {
                min = max = scores[i];
            }
            if(scores[i] < min) {
                min = scores[i];
            } else if(scores[i] > max) {
                max = scores[i];
            }
        }

        minf = 0;
        maxf = 0;
        sum = 0;
        for(int i = 0; i < n; i++) {
            if(!minf && scores[i] == min) {
                minf = 1;
            } else if(!maxf && scores[i] == max) {
                maxf = 1;
            } else {
                sum += scores[i];
            }
        }
        cout << sum / (n - 2) << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,i=0,ans=0,mx=-1,mn=99999999,p;
    while(1){
        cin>>p;
        if(p==0) break;
        for(i=0;i<p;i++){
            cin>>n;
            mx=max(mx,n);
            mn=min(mn,n);
            ans+=n;
        }
        cout<<(ans-mx-mn)/(i-2)<<endl;
        ans=0,mx=-1,mn=99999999;
    }
    return 0;
}

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];
  int max = 0;
  int min = 1000;
  int sum=0;
  while(cin>>n,n){
	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;

  }

  return 0;
}

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

int main(){
  int N;
  while(cin >> N && N>0){
    int pt,total,max,min;
    total=0;
    max=0;
    min=1000;

    for(int i=0;i<N;i++){
      cin >> pt;
      if(pt>max) max=pt;
      if(pt<min) min=pt;
      total+=pt;
    }
    cout << (total-min-max)/(N-2) << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
   int n1;
int main(){
	while (true){
		cin >> n1;
		int a[n1]; if (n1 <= 0) break;
		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>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  t++;
  cin >> N;
  for(ll i = 0; i < N; ++i){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
}
}

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

typedef vector <int> VI;

int main( void )
{
    int n, s;
    while ( cin >> n && n )
    {
        VI v(n);
        for ( int i = 0; i < n; i++ )
        {
            cin >> v[i];
        }
        sort( v.begin(), v.end() );
        
        double sum = 0.0;
        for ( int i = 1; i + 1 < n; i++ )
        {
            sum += v[i];
        }

        int score = (int)floor( sum / ( n - 2 ) );
        cout << score << endl;
    }

    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
 while(true) {
  int n;
  scanf("%d", &n);
  if (!n) break;
  int m=0x7fffffff;
  int M=-0x7fffffff;
  int sum=0;
  rep(i, n) {
   int t;
   scanf("%d",&t);
   sum+=t;
   if(m>t)m=t;
   if(M<t)M=t;
  }
  sum-=m;
  sum-=M;
  printf("%d\n",sum/(n-2));
 }
}

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

int main(){
	/*
	int A[100];
	for (int i = 0; i <= 99; i++){
		A[i] = 99-i;
	}
	sort(A,A+100);
	for (int i = 0; i <= 99; i++){
		cout << A[i] << endl;
	}
	*/

	while(1){
		int n;
		cin >> n;
		if(n == 0){
			break;
		}
		int A[n];
		for (int i = 0; i <= n-1; i++){
			cin >> A[i];
		}
		sort(A,A+n);
		int sum = 0;
		for (int i = 1; i<= n-2; i++){
			sum += A[i];
		}
		cout << (int)(sum/(n-2)) << endl;
	}

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int MIN,MAX,n,sum,a;
int main(){
while(true){
cin>>n;if(!n){break;}
MIN=10000000;
MAX=0;sum=0;
for(i=0;i<n;i++){cin>>a;MIN=min(MIN,a);MAX=max(MAX,a);sum+=a;}
cout<<sum-MIN-MAX<<endl;
}
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while (cin >> n && n) {
    vector<int> score(n);
    rep(i, n)
      cin >> score[i];
    sort(score.begin(), score.end());
    int ans = 0;
    for (int i = 1; i+1 < n; i++)
      ans += score[i];
    ans /= n-2;
    cout << ans << '\n';
  }
  return 0;
}