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>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

namespace Math {
    ll modpow(ll b, ll p, ll m) {
        ll r = 1;
        for (; p; p >>= 1, b = b * b % m)
            if (p & 1)
                r = r * b % m;
        return r;
    }

    ll modinv(ll b, ll m) { return modpow(b, m - 2, m); }

    // Least significant bit.
    ll lsb(ll x) { return x & (-x); }

    template <class T> const T inf() { return 0; }
    template <> const ll inf<ll>() { return 0x3f3f3f3f3f3f3f3fll; }
    template <> const int inf<int>() { return 0x3f3f3f3f; }

    template <class T> T gcd(T a, T b) { return abs(__gcd(a, b)); }
    template <class T> T clamp(T n, T l, T r) { return n < l ? l : n > r ? r : n; }
    template <class T> T lcm(T a, T b) { return abs(a / gcd(a, b) * b); }
    template <class T> T sgn(T n) { return n == 0 ? 0 : n > 0 ? 1 : -1; }

    // Generic modular integer.
    template<int MOD, typename IntType = int>
    struct GModint {
        IntType val;

        GModint() : val(0) {}

        GModint(int v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        GModint(ll v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        explicit operator bool() const { return val != 0; }

        const bool operator==(const GModint &g) const { return val == g.val; }

        const bool operator!=(const GModint &g) const { return val != g.val; }

        const GModint operator+=(const GModint &g) { return *this = *this + g; }

        const GModint operator-=(const GModint &g) { return *this = *this - g; }

        const GModint operator*=(const GModint &g) { return *this = *this * g; }

        const GModint operator/=(const GModint &g) { return *this = *this / g; }

        const GModint operator^=(const GModint &g) { return *this = *this ^ g; }

        const GModint operator-() const { return GModint(val == 0 ? 0 : MOD - val, true); }

        const GModint operator+(const GModint &g) const {
            ll newval = val + g.val;
            if (newval >= MOD)
                newval -= MOD;
            return GModint(newval, true);
        }

        const GModint operator-(const GModint &g) const { return *this + (-g); }

        const GModint operator*(const GModint &g) const { return GModint(1ll * val * g.val); }

        const GModint operator/(const GModint &g) const { return *this * g.inv(); }

        template<class T>
        const GModint operator^(const T t) const { return GModint(modpow(val, t, MOD)); }

        const GModint inv() const { return GModint(modinv(val, MOD)); }
    };

    using Modint = GModint<1000000007>;
}

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

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

        int vmin, vmax, sum = 0;
        for (int i = 1; i <= n; i++) {
            int t; cin >> t;
            sum += t;
            if (i == 1) vmin = vmax = t;
            else vmin = min(vmin, t), vmax = max(vmax, t);
        }

        cout << (sum - vmin - vmax) / (n - 2) << endl;
    } while (true);
}

C++: #include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main(){
	int i,j,k,l,m,n;
	while(cin>>n){
		if(n==0) break;
		int mx=0, mn=2000;
		k=0;
		rep(i,n){
			cin >> m;
			mx = max(mx,m);
			mn = min(mn,m);
			k+=m;
		}
		cout << (k-mx-mn)/(n-2) << endl;
	}
}

C++: #include <iostream>

int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int n;
	int score[1024];

	while (true) {
		std::cin >> n;
		if (!n) break;

		for (int i = 0; i < n; i++) std::cin >> score[i];

		qsort(score, n, sizeof(int), compare);
		double sum = 0;
		for (int i = 1; i < n - 1; i++) sum += score[i];
		int ave = int(sum / (n-2));
		std::cout << ave << '\n';
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    
    while(true){
        int n;
        int max_v = INT_MIN;
        int min_v = INT_MAX;
        int sum = 0;
        cin >> n;
        
        if( n == 0 )return 0;
        
        for(int i = 0 ; i < n ; i++ ){
            int temp;
            cin >> temp;
            sum += temp;
            max_v = max(max_v,temp);
            min_v = min(min_v,temp);
        }
        
        sum -= max_v;
        sum -= min_v;
        
        cout << sum / (n-2) << endl;
    }
    
    return 0;
}

C++: #include <stdio.h>
int main(void){
    int i, score, sum, max, min;
    double ave;
    int n=1;
    scanf("%d", &n);
    while(n!=0){
        ave=0; max=0; min=1000;
        for(i=0;i<n;i++){
            scanf("%d", &score);
            ave = (ave*i + score)/(i+1);
            if(score>max){
                max=score;
            }
            if(score<min){
                min=score;
            }
        }
        ave=(ave*i-min-max)/(i-2);
        printf("%d\n", (int)ave);
        scanf("%d", &n);
    }
    return 0;
}

C++: import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int sum=0,i,max=0,min=1000,ave;
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			for(i=0;i<n;i++){
				int point=sc.nextInt();
				if(point<min){
					min=point;
				}
				if(point>max){
					max=point;
				}
				sum=sum+point;
			}
			ave=(sum-max-min)/(n-2);
			System.out.println(ave);
		}
	}
}

C++: #include <cstdio>

using namespace std;

int main(){
  int min,max,sum,n,score;

  while(1){
    scanf=0("%d",&n);
    if(!n) break;

    max=0;min=10000;sum=0;

    for(int i=0;i<n;i++){
        scanf("%d",&score);
        if(max<score) max=score;
        if(min>score) min=score;
        sum+=score;
    }

    printf("%d",(score-max-min)/(n-2));

    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

	int n;
	int inp;
	int sum,max,min;

	while(1){

		cin>>n;
		if(n==0) break;

		cin>>inp;
		min=inp,max=inp,sum=inp;
		for(int i=1;i<n;i++){
			cin>>inp;
			sum+=inp;
			if(min>inp) min=inp;
			if(max<inp) max=inp;
		}
		cout<<(sum-min-max)/(n-2)<<endl;
	}

	return 0;
}

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

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

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	while(true){
		int n; cin>>n;
		if(n==0)break;
		vector<int>s(n); for(auto&&i:s)cin>>i;
		sort(s.begin(),s.end());
		cout<<accumulate(s.begin()+1,s.end()-1,0)/(n-2)<<"\n"s;
	}
}