Go: // ICPC 得点集計ソフトウェア
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1147&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for	{
		n := nextInt(sc)
		if n == 0 { break }

		score_list := []int{}
		for i := 0; i < n; i++ {
			score_list = append(score_list, nextInt(sc))
		}

		// 最低点と最高点を取り除く (3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1:len(score_list)-1]

		// 平均点を求める
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T = int>inline T in() { T x; cin >> x; return x; }
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REP1(i,n) for(ll i=1;i<=(n);++i)
#define REPI(i,ini,n) for(ll i=(ini);i<(n);++i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b) (((a)+(b)-1)/(b))
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1e9
#define INFL static_cast<ll>(INF)
int main()
{
	while (true)
	{
		int n = in();
		if (n == 0)break;
		vector<int>s(n);
		REP(i, n)s[i] = in();
		sort(ALL(s));
		int sum = 0;
		REP1(i, s.size() - 2)sum += s[i];
		cout << sum / (n - 2) << endl;
	}
}

C++: #include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
#define MAX 20
using namespace std;

int main(void){
  while(true){
    int n;  cin >> n;
    if(n==0)  break;
    int s[MAX], sum=0;
    rep(i, n) cin >> s[i];
    sort(s, s+n);
    FOR(i, 1, n-1)  sum += s[i];
    cout << sum/(n-2) << endl;

  }
  return 0;
}

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

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

signed main() {
	int n; 
	while (cin >> n && n) {
		V v(n); input(v);
		cout << (accumulate(all(v), 0) - *max_element(all(v)) - *min_element(all(v))) / (n - 2) << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int n;
	while (cin >> n && n) {
		vector<int> d(n);
		int sum = 0;
		for (int i = 0; i < n; ++i) cin >> d[i];
		sort(d.begin(), d.end());
		for (int i = 1; i < n - 1; ++i) sum += d[i];
		cout << sum / (n - 2) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        vector<int> v(n);
        for (auto &&i : v) scanf("%d", &i);
        int s = 0;
        sort(v.begin(), v.end());
        for (int i = 1; i < n-1; ++i) {
            s += v[i];
        }
        printf("%d\n", s/(n-2));
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    vector<int> a;
    while(cin>>n){
        if(n==0)break;
        a.clear();
        for(int i = 0; n > i; i++){
            int tmp;cin>>tmp;
            a.push_back(tmp);
        }
        sort(a.begin(),a.end());
        int sm = 0;
        for(int i = 1; a.size()-1 > i; i++){
            sm += a[i];
        }
        cout << sm/(n-2) << endl;
    }
}

C++: #include <iostream>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

using namespace std;

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

C++: #include<iostream>

#define     MIN_POINT     0
#define     MAX_POINT     1000

using namespace std;

int main(){
	int n;

	// ループ
	cin >> n;
	while(n >= 3){
		int min = (int)(MAX_POINT), max = (int)(MIN_POINT);
		int sum = (min + max) * (-1);
		int i, buf;

		// 点数の入力・合計処理
		for(i=0;i<n;i++){
			// 入力
			cin >> buf;
			// 入力値のチェック
			if((buf < ((int)(MIN_POINT))) || (buf > ((int)(MAX_POINT)))){
				cerr << "入力された値が範囲外です" << endl;
				i--;
				continue;
			}
			// 合計値に加算
			sum += buf;
			// 最大値のチェック
			if(buf > max){
				sum += max;
				max = buf;
				sum -= max;
			}
			// 最小値のチェック
			if(buf < min){
				sum += min;
				min = buf;
				sum -= min;
			}
		}

		// 合計の表示
		cout << (sum / (n - 2)) << endl;

		// 入力
		cin >> n;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int N;
    int ans;
    int cnt;
    vi vec(20);
    while(true){
        vec.assign(20, -1);
        ans = 0;
        cnt = 0;
        cin >> N;
        if(N == 0) return 0;
        rep(i, N){
            cin >> vec[i];
        }
        vsort(vec);
        REP(i, 21 - N, 19){
            ans += vec[i];
            cnt++;
        }
        cout << (int)(ans / cnt) << endl;
    }


    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
    int n, max = 0, min = 0, sum = 0;
    while(cin >> n && n > 0){
        int s[n];
        for (int i = 0; i < n; i++ ){
            cin >> s[i];
            sum += s[i];
        }
        for (int i = 0; i < n; i++){
            if (s[i] > max)
                max = s[i];
        }
        for (int i = 0; i < n; i++){
            if (s[i] < min)
                min = s[i];
        }
        cout << (sum - max - min)/(n - 2) << endl;
    }
}

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

using namespace std;

int main(int, char**){
	int n;
	vector<int> ret;
	while(true){
		int n,buf;
		vector<int> scores;
		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; ++i){
			cin >> buf;
			scores.push_back(buf);
		}
		scores.erase(max_element(scores.begin(),scores.end()));
		scores.erase(min_element(scores.begin(),scores.end()));
		ret.push_back( std::accumulate(scores.begin(), scores.end(), 0) / scores.size() );
	}

	for(int av : ret){
		cout << av << endl;
	}
	return 0;
}

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

int main(){
int num,temp;

while(1){
   cin>>num;
   if(num==0){
   break;
   }
   int min=10000000,max=0,sum=0;
   for(int i=0;i<num;i++){
   cin>>temp;
   if(min>temp)min=temp;
   if(max<temp)max=temp;
   sum+=temp;
   }
   sum=sum-max-min;
   cout<<sum/(num-2)<<endl;
}

return 0;
}