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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) return 0;
        
        vector<int> A(N);
        for(int i=0;i<N;i++) cin>>A[i];
        sort(all(A));
        
        ll sum=0;
        
        for(int i=1;i<N-1;i++) sum+=A[i];
        cout<<sum/(N-2)<<endl;
    }
}

C++: #include <cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int maxi=0,mini=1000,sum=0;
		rep(i,n){
			int a; scanf("%d",&a);
			sum+=a;
			if(maxi<a) maxi=a;
			if(mini>a) mini=a;
		}
		printf("%d\n",(sum-maxi-mini)/(n-2));
	}

	return 0;
}

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

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

	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define endl '\n'
const int INF = (1 << 30);
using namespace std;
typedef long long int ll;

bool solve(){
    int n, smax=0, smin=INF, sum=0, s;
    cin >> n;
    if(!n) return false;
    REP(i,n){
        cin >> s;
        smax = max(s, smax);
        smin = min(s, smin);
        sum += s;
    }
    cout << (sum - smin - smax) / (n-2) << endl;
    return true;
}

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

    while(solve());
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    int in;
    int num;
    int ans=0;
    int point[105]={};
    while(1==1)
    {
        
        scanf("%d\n",&in);
        if(in==0)return 0;
        num=in;
        ans=0;
        REP(i,num)
        {
            scanf("%d\n",&point[i]);
            ans+=point[i];
        }
        sort(point[0],point[num]);
        ans-=(point[0]+point[num-1]);
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int main(){

	while (1){
		int n;
		int sum = 0;
		cin >> n;

		if (n == 0){
			return 0;
		}

		int s;
		int max = -1;
		int min = 9999;
		for (int i = 0; i < n; i++){
			cin >> s;
			sum += s;
			if (s >= max){
				max = s;
			}
			if (s <= min){
				min = s;
			}
		}
		int ans = floor((sum - max - min) / (n - 2));
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main(void){
int n;
while(1){
	cin>>n;
	if(n==0)break;
	int b;
	priority_queue<int> a;
	for(int i=0;i<n;i++){
		cin>>b;
		a.push(b);
	}
	a.pop();
	int ans=0,c;
	while(a.size()!=1){
ans+=a.top();
a.pop();
	}
	ans/=n-2;
	cout<<ans<<endl;
}
	return 0;
}

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

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

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

int main() {
    vector<int> avg;
    while(true) {
        int n;
        cin >> n;
        if(n==0)
            break;

        vector<int> v(n);
        int sum = 0;
        int ma = -1;
        int mi = 10000;
        for(int i=0;i<n;i++) {
            int vi;
            cin >> vi;
            ma = max(ma, vi);
            mi = min(mi, vi);
            sum += vi;
        }

        sum = sum - ma - mi;
        avg.push_back(sum/(n-2));
    }
    for(int i=0;i<avg.size();i++)
        cout << avg[i] << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		ll n;
		cin>>n;
		if(n==0) break;
		vector<ll> s(n);
		REP(i,n) cin>>s[i];
		sort(ALL(s));
		ll sum=accumulate(ALL(s),0);
		sum-=s[0]+s[n-1];
		cout<<sum<<endl;
	}
}

C++: #include <iostream>
using namespace std;
 
int main() {
	int n;
	while(1){
	cin >> n;
	if(n==0)break;
	int min,max;
	int s,x;
	cin >>s;
	min=s;
	max=s;
	x=s;
		for(int i=0;i<n-1;i++){
		cin >>s;
		x=x+s;
		if(min >s) min=s;
		if(max <s) max=s;
 
		}
	x=x-max-min;
    x=x/(n-2);
	cout << x <<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int n;
	while (cin >> n, n)
	{
		int s[1024];
		rep (i, n)
			cin >> s[i];
		sort(s, s + n);
		cout << accumulate(s + 1, s + (n - 1), 0) / (n - 2) << endl;
	}
}