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;
	cin >> n;
	while(n){
		int p[100];
		for(int i = 0; i < n; i++){
			cin >> p[i];
		}
		sort(p,p+n);
		int a = 0;
		for(int i = 1; i < n-1; i++){
			a += p[i];
		}
		cout << a/(n-2) << endl;
		cin >> n;
	}
}

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

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int ma=0, mi=1000000000;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int buf; cin >> buf;
			ma = max(ma, buf);
			mi = min(mi, buf);
			ans += buf;
		}
		cout << (ans - ma - mi) / (n - 2) << endl;
	}
}

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

int main() {
  int n, tmp;
  while(cin >> n && n != 0){
    vector<int> s;
    for(int i = 0; i < n; i++) {
      cin >> tmp;
      s.push_back(tmp);
    }
    sort(s.begin(), s.end());
    s.erase(s.begin()); s.erase(s.end() - 1);
    tmp = 0;
    for(auto i: s) {
      tmp += i;
    }
    cout << tmp / (n - 2)<< endl;
  }
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

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

  while(true) {
    int n;
    cin >> n;
    vector<int> v;
    int a;
    rep(i, n) {
      cin >> a;
      v.push_back(a);
    }
    sort(ALL(v));

    int sum = 0;
    for(int i = 1; i < n - 1; i++) {
      sum += v[i];
    }
    sum = sum / (n - 2);
    cout << sum << endl;
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

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

using namespace std;

int main() {
    int n;

    while(cin >> n, n) {
        vector<int> judge(n);
        int sum = 0;

        REP(i, n) {
            cin >> judge[i];
        }
        sort(judge.begin(), judge.end());

        REP(i, n-2) {
            // cout << judge[i+1] << endl;
            sum += judge[i+1];
        }
        cout << (sum/(n-2)) << endl;

    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    while (1) {
        int n;
        cin >> n;
        if (!n) return 0;

        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        int sum = 0;
        for (int i = 1; i < n - 1; ++i) {
            sum += a[i];
        }
        cout << sum / (n - 2) << "\n";
    }
}

C++: // Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int S[100];

		int sum = 0;

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

		sort(S, S+n);

		cout << (sum-S[0]-S[n-1])/(n-2) << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
const int INF = 1e9;


int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    vector<int> a(n);
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    sort(a.begin(),a.end());
    a.erase(a.end()-1);
    a.erase(a.begin());
    int sum=0;
    for(int i=0;i<a.size();i++){
      sum+=a[i];
    }
    cout<<sum/a.size()<<endl;
  }
  return 0;
}

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

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

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector<int> scores;
        repeat(i, n) {
            int s; cin >> s;
            scores.push_back(s);
        }
        int max_s, min_s;
        max_s = *max_element(scores.begin(), scores.end());
        min_s = *min_element(scores.begin(), scores.end());
        int sum = -max_s-min_s;
        repeat(i, n) {
            sum += scores[i];
        }
        int average = sum / (n-2);
        cout << average << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main () {

  while (true){

    int n;
    int i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0)
      break;
??????
??????int p[100];

    for (i = 0;i < n;i++){
      cin >> p[i];

      if (p[i] < mi)
        mi << p[i];

      if (p[i] > ma)
        ma << p[i];

      s += p[i];

    }

    cout << (s - mi - ma) / (n-2) << endl;

  }

  return 0;

}

C++: #include <iostream>
using namespace std;
int N, S;
int main () {
  while (cin >> N && N>0) {
    int sum = 0;
    int largest = 0;
    int smallest = 1000;
    for (int i=0; i<N; ++i) {
      cin >> S;
      sum += S;
      if (largest < S) largest = S;
      if (smallest > S) smallest = S;
    }
    int average = (sum - largest - smallest) / (N-2);
    cout << average << endl;
  }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int sum = 0, x, total, ans;
  vector<int> p(0);
  int n;
  
    while(1){
      cin >> n;
      if(n==0)
      break;
      for(int i=0; i<n; i++){
        cin >> x;
        p.push_back(x);
      }

      int max = *max_element(p.begin(), p.end());
      int min = *min_element(p.begin(), p.end());

      for(int i=0; i<n; i++){
        sum += p[i];
      }
      total = sum - min - max;
      ans = total / (n-2);
      cout << ans << endl;
    } 

  return 0;
}

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

int n,s[100];
int temp,ave,sum;

void sort(void){
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(s[i]>s[j]){
	temp=s[i];
	s[i]=s[j];
	s[j]=temp;
      }
    }
  }
}

int main(){
  while(cin >> n,n){
    for(int i=0;i<n;i++)
      cin >> s[i];  
    
    sort();
    
    sum=0;

    for(int i=0;i<n-2;i++)
      sum+=s[i+1];

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

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

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

  }
}