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 <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
auto constexpr infty<int> = 1'100'100'100;
template<>
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  int N;
  while (cin >> N && N) {
    vector<lli> scores;
    REP(i, N) {
      lli S; cin >> S;
      scores.push_back(S);
    }
    sort(begin(scores), end(scores));
    scores[0] = scores[N-1] = 0;
    cout << accumulate(begin(scores), end(scores), 0) / (N-2) << endl;
  }
  return 0;
}

C++: #include<utility>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<stack>
#include<complex>
#include<cmath>
#include<iostream>
#include<set>
#include<map>
#include<sstream>
#include<fstream>
#include<climits>
#include<chrono>
#include<random>
#include<functional>
#include<regex>

using namespace std;
typedef pair<int, int> P;
typedef long long ll;

// ??§????????°INF
const int INF = (1 << 30);
// ?¨±?????????????????
const double EPS = (1e-10);
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)


int main()
{
	int n;
	while (true) {
		cin >> n;
		if (n == 0)break;
		vector<int> judges(n);
		int total = 0;
		for (int i = 0; i < n; ++i) {
			cin >> judges[i];
			total += judges[i];
		}
		int M = *max_element(judges.begin(), judges.end()),m=*min_element(judges.begin(),judges.end());
		total -= (M + m);
		int ans = total / (n - 2);
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for (;;) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		int mi = 100000000;
		int ma = 0;
		int sum = 0;
		rep(i, n) {
			int a;
			cin >> a;
			mi = min(a, mi);
			ma = max(a, ma);
			sum += a;
		}
		sum -= (mi + ma);
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

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

int main() {
	int n, a, sum;
	multiset<int> s;
	multiset<int>::iterator it2;
	while(1) {
		cin >> n;
		if(!n) break;
		s.clear();
		for(int i=0; i<n; ++i) {
			cin >> a;
			s.insert(a);
		}
		s.erase(s.begin());
		s.erase(--s.end());
		sum = 0;
		for(multiset<int>::iterator it=s.begin(); it!=s.end(); ++it) {
			sum += (*it);
		}
		cout << (sum/(n-2)) << endl;
	}
	return 0;
}

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

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

C++: #include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

// boost
#define USE_BOOST_IN_CODE
#ifdef USE_BOOST_IN_CODE
#include <boost\range.hpp>
#include <boost\range\algorithm.hpp>
#include <boost\range\numeric.hpp>
#include <boost\range\irange.hpp>
#include <boost\range\adaptor\strided.hpp>
#include <boost\range\adaptor\transformed.hpp>
#include <boost\format.hpp>
#endif


using ll = long long;

//vector
template <class T>
using vec = std::vector<T>;

//namespace std
//{
//    template<>
//    class hash<Key>
//    {
//    public:
//        size_t operator() (const Key& key) const
//        {
//            size_t seed = 0;
//            auto i_hash = hash<int>()(key.i_th);
//            auto w_hash = hash<int>()(key.W);
//
//            seed ^= i_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
//            seed ^= w_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
//
//            return seed;
//        }
//    };
//}

void solve()
{
    using namespace std;

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

        vec<int> v(n);
        for (auto& x : v)
            cin >> x;

        boost::sort(v);

        cout << accumulate(v.cbegin() + 1, v.cend() - 1, 0) / (n - 2) << endl;
        ++count;
    }

}

int main()
{
    solve();
    return 0;
}

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

int main(int argc, const char * argv[]) {
    while(1){
        int n; cin >> n;
        if(!n) break;
        
        int big = -1, small = 1001;
        int sum = 0;
        for(int i = 0; i < n; i++){
            int point; cin >> point;
            big = max(big, point);
            small = min(small, point);
            sum += point;
        }
        cout << (sum - big - small) / (n - 2) << endl;
    }
}

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

int main()
{
  int n;
  while(cin >> n && n != 0){
    int maximum = 0, minimum = 1000, sum = 0, s;
    for(int i = 0 ; i < n; ++i){
      cin >> s;
      maximum = max(maximum, s);
      minimum = min(minimum, s);
      sum += s;
    }
    sum = sum - maximum -minimum;
    cout << sum/(n - 2) << endl;
  }
  return 0;
}