Go: package main

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

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

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

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

		score_list := []int{}
		for i := 0; i < num; 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))
	}
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    while(true){
        int n; cin >> n; if(n ==0 ) break;
        int sum = 0; int cou = 0;
        vi v(n,INF);
        rep(i,n){cin >> v[i];}
        rep(i,n) cout << v[i] << endl;
        CC
        sort(v.begin(),v.begin()+n);
        CC
        v.erase(v.begin());
        v.erase(v.end()-1);
        rep(i,n-2){
            sum+=v[i]; cou++;
        }
        cout << sum /cou << endl;
    }
}

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

using namespace std;

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

}

C++: #define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   	int a;
   	while(1){
	cin >> a;
	if (a == 0) break;
	
	vector<int> v(a);
	for (int i = 0; i < a; i++) cin >> v[i];
	sort(all(v));
	int sum = 0;
	for (int i = 1; i < a - 1; i++) sum += v[i];
	cout << sum / (a - 2) << endl;	
  }
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}

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

using namespace std;

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


	while(1){
	cin>>n;
	max = 0;
	min = 1000;
	if(n==0){
		for(i=0;i<ans.size();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>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        int ma = 0;
        int mi = 1000;
        int s = 0;
        cin >> n;

        if(n == 0){
            break;
        }

        int a[n];

        for(int i=0;i<n;i++){
            cin >> a[i];
            if(ma < a[i]){
                ma = a[i];
            }
            if(mi > a[i]){
                mi = a[i];
            }
            s += a[i];
        }

        cout << (s - ma - mi)/(n - 2) << endl;
    }   
 
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
  while(1){
    int n;
    cin >> n;
    if(n == 0)break;
    vector<int> array(n,0);
    int max_a = 0;
    int min_a = 10000;

    for(int i = 0;i < n;i++){
      int tmp;
      cin >> tmp;
      array[i] = tmp;
      max_a = max(max_a,tmp);
      min_a = min(min_a,tmp);

    }

    int sum = -1*(max_a + min_a);
    for(int i = 0; i < n;i++){
	sum += array[i];
    }
    cout << (int)(sum / (n-2)) << endl;
  }
  return 0;
}

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

C++: #include <stdio.h>

int max = 0;
int min = 1000;

int maximum(int s)
{
	if(max < s){ max = s; }
	
	return max;
}


int minimum(int s)
{
	if(min > s){ min = s; }
	
	return min;
}


int main(void)
{
	int n;
	int i;
	int s;
	
	while(scanf("%d", &n) != EOF){
		if(n == 0){ break; }
		int ans = 0;
		int maxi, mini;
		for(i = 0; i < n; i++){
			scanf("%d", &s);
			maxi = maximum(s);
			mini = minimum(s);
			ans += s;		
		}
		ans = (ans - maxi - mini) / (n - 2);
		printf("%d\n", ans);
		
		max = 0;
		min = 1000;
	}
	return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

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