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>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
//---------------------------------------------------------------------------//
int n,sum=0;
int a[101];
int main(){
        cin>>n;
        for(int i=0; i<n; i++) {
                cin>>a[i];
        }

        sort(a,n);
        for(int i=1; i<n-1; i++) {
                sum+=a[i];
        }
        cout<<sum<<endl;
}

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

int main() {
    int n;
    while(cin >> n, n){
        int sum=0,ma=0,mi=IINF;
        REP(i,n){
            int a;
            cin >> a;
            sum+=a;
            ma = max(ma, a);
            mi = min(mi, a);
        }
        cout << (sum-ma-mi)/(n-2) << endl;
    }
    return 0;
}

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

int N, S;
void solve(){
    while (cin >> N && N > 0){
        int sum = 0;
        int min = 1000000;
        int max = -1;
        for (int i = 0; i < N; i++){
            cin >> S;
            sum += S;
            if (min > S) min = S;
            if (max < S) max = S;
        }
        cout << (sum - max - min)/(N-2) << endl;
    }
}



int main(){
    solve();
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,s,m,M,ans;
	cin>>n;
	m = 1005;
	M= -1;
	ans=0;
	for(int i=0;i<n;i++){
		cin>>s;
		m=min(m,s);
		M=max(M,s);
		ans+=s;
	}
	n-=2;
	ans=ans-M-m;
	ans /= n;
	cout<<ans<<endl;

}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(x) x.begin(),x.end()


void solve(){
    int N;cin>>N;
    if(N==0)exit(0);
    vector<int>A(N);
    REP(i,N)cin>>A[i];
    sort(ALL(A));
    int sum = 0;
    FOR(i,1,N-1)sum+=A[i];
    cout<<sum/(N-2)<<endl;
}
signed main(){
    while(true){
        solve();
    }
}

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

int main()
{
	int in,a,maxer=0,miner=1000;
	int sum=0;
	int i=0;
	double ave=0.0;
	while( scanf("%d",&in) !=0 ){
		for(i=0; i<in; i++){
			cin >> a;
			maxer=max(a,maxer);
			miner=min(a,miner);
			sum += a;
		}
		sum = sum - maxer - miner;
		ave = sum/(in-2);
		cout << floor(ave) << endl;
		sum = maxer = ave = 0;
		miner=1000;
	}
}

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

int main(){
	int n;
	int s[100];
	int sum;
	
	cin >> n;
	while(n > 2){
		for(int i=0; i<n; ++i){
			cin >> s[i];
		}
		
		sort(s, s+n);
		
		sum=0;
		for(int i=1; i<(n-1); ++i){
			sum+=s[i];
		}
		
		cout << sum/(n-2) << endl;
		cin >> n;
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	while(true){
		int n;
		cin >> n;
		if(n==0){
			break;
		}
		const int MAXN=100;
		int a[MAXN];

		for(int i=0; i<n; i++){
			cin >> a[i];
		}
		int max=a[0], min=a[0], kei=0;
		for(int i=0; i<n; i++){
			if(max < a[i]){
				max=a[i];
			}
			if(min > a[i]){
				min=a[i];
			}
			kei+=a[i];
		}
		int heikin;
		heikin=(kei-max-min)/(n-2);
		cout << heikin << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

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

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

using namespace std;

int main(){
	vector<int> array;
	vector<int> ans;
	int i,x,max,min,sum,n;
	max = 0;
	min = 1000;

	while(1){
	cin>>n;
	if(n==0){
		for(i=0;i<sizeof(ans);i++){
			cout<<ans[i]<< endl;
		}

		break;
	}
	array.clear();
	sum=0;

	for(i=0;i<n;i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<n;i++){
		sum += array[i];
	}
	sum = sum-max-min;
	ans.push_back(sum/(n-2));  //2ひいた分だけ割る数を減らす 
	}

}

C++: #include<iostream>
using namespace std;
int N,S;

int main() {
	while (cin >> N && N>0) { // By while (), adopt the form of std in 
		int sum = 0;
		int max = 0;
		int min = 0;
		for (int i=0; i<N; i++) {
			cin >> S;
			sum += S; // calculate sum
			if (max < S) max = S; // search max
			if (min > S) min = S; // search min
		}
		int ans;
		ans = (sum-max-min)/(N-2);
		cout << ans << endl;
	}
	return 0;
}

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

using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::sort;

void input(vector<int>& v, int number) {
    for (int i = 0; i < number; i ++) { 
        int value;
        cin >> value;
        v.push_back(value);
    }   
    sort(v.begin(), v.end());
}

void calc(vector<int> v) {
    int total = 0;
    int average;
    int size = v.size();
    for (int i = 1; i < size - 1; i ++) {
        total += v[i];
    }   
    average = total / (size - 2); 
    cout << average << endl;
}

int main(void) {
    int number;
    cin >> number;
    while (number != 0) {
        vector<int> v(0);
        input(v, number);
        calc(v);
        cin >> number;
    }   
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>



using namespace std;



int main()
{
	int n, s, sum;
	
	while (cin >> n)
	{
		if (n == 0) break;
		
		vector<int> vi;
		for (int i=0; i<n; i++)
		{
			cin >> s;
			vi.push_back(s);
		}
		
		sort(vi.begin(), vi.end());
		
		/*
		//テスト出力
		for (int i=0; i<vi.size(); i++)
		{
			cout << vi[i] << endl;
		}
		*/
		
		sum = 0;
		for (int i=1; i<vi.size()-1; i++)
		{
			sum += vi[i];
		}
		
		cout << sum / (vi.size() - 2) << endl;
	}
	
	return 0;
}