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

int main(){
  int i,n,sum = 0;
  int pt[1000];
  while(cin>>n,n){
    sum = 0;
    for(i = 0;i<n;i++) cin>>pt[i];
    sort(pt,pt + n);
    for(i = 1;i<n-1;i++){
      //cout<<pt[i]<<endl;
      sum += pt[i];
    }
    int tmp = sum/(n-2);
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main() {
    int n, min, max, sum, p;
    while (true) {
        cin >> n;
        if (n == 0) {
            break;
        }
        sum = 0;
        for (int i=0; i<n; i++) {
            cin >> p;
            sum += p;
            if (i == 0) {
                min = p;
                max = p;
            }
            min = p<min? p: min;
            max = p>max? p: max;
        }
        cout << (sum-min-max)/(n-2) << endl;
    }
    return 0;
}

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

int main(){
  int N;
  
  while(cin>>N){
    if(N==0){
      break;
    }
    int max=0,min=1001,sum=0,a;
    for(int i=0;i<N;i++){
      cin >>a;
      if(max<a){ max=a; }
      if(min>a){ min=a; }
      sum+=a;
  }
    sum-=max;
    sum-=min;
    int ave = sum/(N-2);
    cout << ave <<endl;
  }

  return 0;
}

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

int main(){
  int n, a[100], s;
  while(cin >> n,n){
    s=0;
    for(int i = 0;i < n;i ++){
      cin >> a[i];
    }
    sort(a,a+n);
    for(int i = 1;i < n-1;i ++){
      s += a[i];
    }
    cout << s/(n-2)<< endl;
  }
  return 0;
}

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

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

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

        int max=0,min=1000;;

        for(int i=0;i<n;i++){
            if(s[i]>max)max=s[i];
            else if(s[i]<min)min=s[i];
        }
        
        int sum=0;
        for(int i=0;i<n;i++){
            sum +=s [i];
        }


        sum -=max;
        sum -=min;

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

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll T[N];
  ll sum=0;
  for(ll i=0; i<N; ++i){
    cin>>T[i];
    sum+=T[i];
  }
  cout<<sum/N<<endl;
  
}

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

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

		int s[100];
		int max = 0, min = 1000;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			if (max < s[i]) {
				max = s[i];
			}
			if (min > s[i]) {
				min = s[i];
			}
		}

		bool flag_max = true;
		bool flag_min = true;
		int total = 0;
		for (int i = 0; i < n; i++) {
			if ((s[i] == max) && flag_max) {
				flag_max = false;
				continue;
			} else if ((s[i] == min) && flag_min) {
				flag_min = false;
				continue;
			} else {
				total += s[i];
			}
		}
		int ave = total / (n - 2);
		printf("%d\n", ave);
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

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

    int n, p;
    vector<int> v;
    while(true){
        cin >> n;
        if(n == 0) break;
        
        rep(n){
            cin >> p;
            v.push_back(p);
        }
        sort(all(v));
        cout << accumulate(v.begin()+1, v.end()-1, 0) / (n-2) << endl;
        v.clear();
    }
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL 10000000000000000LL
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  while(true){
    int n;
    cin >> n;
    if(n == 0) return 0;
    int a[n];
    REP(i, n) cin >> a[i];
    sort(a, a+n);
    int sum = 0;
    FOR(i, 1, n-1){
      sum += a[i];
    }
    cout << sum/(n-2) << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n;
    scanf("%d",&n);
    while(n!=0){
        vector<int> s;
        int sum=0;
        REPR(i,n-1){
            int sn;
            scanf("%d",&sn);
            s.push_back(sn);
        }
        sort(s.begin(),s.end());
        FOR(i,1,s.size()-1){
            sum=sum+s[i];
        }
        int ave=sum/(n-2);
        printf("%d\n",ave);
        scanf("%d",&n);
    }
    return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int a[111];
int main(void){
  while(cin >> n && n){
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    int sum = 0;
    for(int i = 1; i < n-1; i++) sum += a[i];
    cout << sum/(n-2) << endl;
  }
}

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

using namespace std;

int main() {
	int N;
	while(cin >> N && N) {
		vector<int> tmp(N);
		int score_max = 0;
		int score_min = 1001;
		int res = 0;
		for(int i = 0; i < N; i++) {
			cin >> tmp[i];
			score_max = max(score_max, tmp[i]);
			score_min = min(score_min, tmp[i]);
			res += tmp[i];
		}
		cout << (res - (score_max+score_min))/(N-2) << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    int n;
    int score;
    int sum;
    int max, min;
    cin >> n;
    while(n){
        sum = 0;
        max = 0;
        min = 1000;
        for(int i=0;i<n;++i){
            cin >> score;
            sum += score;
            if(score > max){
                max = score;
            }
            if(score < min){
                min = score;
            }
        }
        sum = sum - max - min;
        cout << sum/(n-2) << endl;
        cin >> n;
    }
}