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 n;
    while(cin >> n && n){
        int mini = 1 << 29;
        int maxi = -1;
        int sum = 0;
        int tmp;
        for(int i=0;i<n;i++){
            cin >> tmp;
            mini = min(mini, tmp);
            maxi = max(maxi, tmp);
            sum += tmp;
        }
        cout << (sum - mini - maxi) / (n - 2) << endl;
    }
}

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

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

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

using namespace std;

int main(){
	int n;
	while(cin >> n){
		if(n==0) break;
		int m = 9999999, M = 0, sum = 0;
		for(int i=0;i<n;i++){
			int tmp; cin >> tmp;
			m = min(m,tmp);
			M = max(M,tmp);
			sum += tmp;
		}
		cout << ((sum-m-M)/(n-2)) << endl;
	}
}

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

C++: #include <iostream>

using namespace std;

int main(void)
{
	int n;
	while(cin >> n, n > 0){
		int s, sum = 0, maxi, mini;
		cin >> s;
		sum += s;
		maxi = s;
		mini = s;
		for(int i = 1; i < n; i++){
			cin >> s;
			sum += s;
			maxi = max(maxi, s);
			mini = min(mini, s);
		}
		cout << (sum-maxi-mini)/(n-2) << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
class Score{
private:
	int shinpan;
	int score[100];
	int max;
	int min;
	int ave;
public:
	Score();
	//????????????????????¨????????????????????¨???
	void Reset();
	//???????????°?????\???
	void InputShinpan(int n){shinpan = n;}
	//?????°??????????????°?????¨?????\?????????
	void InputScore();
	//????????????????????????????????????????????°?????????
	int ReturnAverage();
};
Score::Score(){
	max=INT_MIN;
	min=INT_MAX;
	ave=0;
	shinpan=0;
	for(int i=0;i<100;i++){
		score[i] = INT_MIN;
	}
}
void Score::Reset(){
	max=INT_MIN;
	min=INT_MAX;
	ave=0;
	shinpan=0;
	for(int i=0;i<100;i++){
		score[i] = INT_MIN;
	}
}
void Score::InputScore(){
	for(int i=0;i<shinpan;i++){
		cin >> score[i];
	}
}
int Score::ReturnAverage(){
	for(int i=0;i<shinpan;i++){
		ave += score[i];
		if(score[i]>max){
			max = score[i];
		}
		if(score[i]<min){
			min = score[i];
		}
	}
	ave -= max;
	ave -= min;
	ave = ave / (shinpan - 2);
	return ave;
}
int main()
{
	int n;
	int i;
	Score score;
	while(cin>>n,n!=0){//???????????°?????\??? ?????§??????
		score.InputShinpan(n);
		score.InputScore();
		cout << score.ReturnAverage() << endl;
		score.Reset();
	}
	cin.get();
	return 0;
}

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

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

using namespace std;

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

typedef long long ll;

void solve(){
}

int main(){
  int n;

  while(cin>>n,n){
    int sum = 0;
    int max = INT_MIN;
    int min = INT_MAX;

    rep(i,n){
      int s;
      cin>>s;
      sum += s;

      if(max < s) max = s;
      if(min > s) min = s;
    }

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

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
 
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
 
using namespace std;

int main(){

  while(true){

    int a;
    cin >> a;

    vector<int> list;

    if(a==0){
      break;
    }

    rep(i,a){
      int temp=0;
      cin >> temp;
      list.push_back(temp); 
    }

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

    int ans=0;
    int count=0;
    REP(i,1,a-1){
      ans+=list[i];
      count++;
    }
    ans=(int)(ans/count);
    cout << ans << endl;
  }
  return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define INF 1e09

using namespace std;

int main(){
  int n;
  int total, maxim, minim;
  int tmp;
  while(cin >> n and n){
    total = 0; maxim = -INF; minim = INF;
    REP(i, n) { cin >> tmp; total += tmp; maxim = max(maxim, tmp); minim = min(minim, tmp); }
    total -= (maxim + minim);
    cout << total / (n - 2) << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0){
      break;
    }
    vector<int> a(n);
    int ma=0;
    int mi=1000;
    int sum=0;
    rep(i,n){
      cin >> a[i];
      ma=max(a[i],ma);
      mi=min(a[i],mi);
      sum+=a[i];
    }
    sum=sum-mi-ma;
    int ave=sum/(n-2);
    cout << ave << endl;
  }
  return 0;
  
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int maxi = -1;
        int mini = 1e9;
        int sum = 0;
        for(int i = 1; i <= n; i++) {
            int in;
            cin >> in;
            maxi = max(maxi, in);
            mini = min(mini, in);
            sum += in;
        }
        cout << (sum - maxi - mini) / (n - 2) << endl;

    }
    return 0;
}