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 <bits/stdc++.h>
using namespace std;

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

signed main() {
  while (true) {
    i32 n;
    cin >> n;
    if (n == 0) break;
    vector<i32> s(n);
    cin >> s;
    sort(ALL(s));
    i64 sum = 0;
    FOR(i, 1, n - 1) {
      sum += s[i];
    }
    i64 ans = sum / (n - 2);
    cout << ans << endl;
  }
}

C++: #include <bits/stdc++.h>
using Int = int64_t;

int main() {
   for(;;) {
      Int n;
      std::cin >> n;
      if( n == 0 ) break;
      std::vector<Int> xs(n);
      for(Int i = 0; i < n; ++i) {
         std::cin >> xs[i];
      }
      std::sort(xs.begin(), xs.end());
      Int total = 0;
      for(Int i = 1; i < (Int)xs.size()-1; ++i) {
         total += xs[i];
      }
      Int res = total / (n-2);
      std::cout << res << std::endl;
   }
}

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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

int main()
{
    int n;

    while (cin >> n, n)
    {
        int s = 0;
        int maxs = 0, mins = iINF, sum = 0;

        rep(i, n)
        {
            cin >> s;
            maxs = max(maxs, s);
            mins = min(mins, s);
            sum += s;
        }

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

    return 0;
}

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

using namespace std;

int main(){
  int n;
  while(cin>>n){
    if(n==0)break;
    vector<int> score(n);
    for(int i=0;i<n;i++)cin>>score[i];

    vector<int>::iterator minIt = min_element(score.begin(),score.end());
    int minIndex = distance(score.begin(),minIt);
    score.erase(score.begin()+minIndex-1);

    vector<int>::iterator maxIt = max_element(score.begin(),score.end());
    int maxIndex = distance(score.begin(),maxIt);
    score.erase(score.begin()+maxIndex-1);

    int sum = accumulate(score.begin(),score.end(),0);
    cout << sum/score.size() << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
  int n, a[21], t;

  while(cin>>n && n){
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    sort(a, a+n);
    t = 0;
    for(int i = 1; i < n-1; i++){
      t += a[i];
    }

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

  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

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

        int sum = 0, min_ = 1001, max_ = -1;
        for (int i = 0; i < n; i++) {
            int s;
            cin >> s;
            sum += s;
            min_ = min(min_, s);
            max_ = max(max_, s);
        }

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

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long sum[20];
	int j=0;
	while(true){
		int n;
		cin >> n;
		if(n==0)break;
		int s[n];
		sum[j] = 0;
		for (int i = 0; i < n; ++i)
		{
			cin>>s[i];
			sum[j]+=s[i];
		}
		sort(s,s+n);
		sum[j] -= s[0]+s[n-1];
		sum[j] = sum[j]/(n-2);
		j++;
	}
	for (int i = 0; i < j; ++i)
	{
		cout << sum[i] <<endl;
	}
	return 0;
}

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

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

C++: #include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
int flag = 1;

int main(){
    cin >> flag;
    while(flag){
        int temp = 0, score = 0;
        int M = 0, m = 1000;
        REP(i,flag){
            cin >> temp;
            score += temp;
            M = max(temp,M);
            m = min(temp,m);
        }
        cout << (score-M-m)/(flag-2) << endl;
        cin >> flag;
    }
    return 0;
}