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;

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9+7;


signed main(){
    while (true) {
        int n;
        cin >> n;
        if (n==0) { break; }
        vector<int> v;
        for(int i=0; i<n; i++) {
            int p;
            cin >> p;
            v.push_back(p);
        }
        sort(v.begin(),v.end());
        int sum = 0;
        for(int i=1; i<n-1; i++) {
            sum += v[i];
        }
        cout << sum/(n-2) << endl;
    }
}

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

int main(int argc, char const *argv[])
{
	int n;
	while(cin>>n,n)
	{
		int t;
		cin>>t;
		int s=t,mi=t,ma=t;
		for (int i = 1; i < n; ++i)
		{
			cin>>t;
			s+=t;
			mi=min(mi,t);
			ma=max(ma,t);
		}
		cout<<(s-ma-mi)/(n-2)<<endl;
	}
	return 0;
}

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

int main(){
	int n, s, sum, maxs, mins, i;
	while((cin >> n), n){
		sum = maxs = 0;
		mins = 1000;
		for(i = 0; i < n; i++){
			cin >> s;
			sum += s;
			maxs = max(maxs, s);
			mins = min(mins, s);
		}
		cout << (int)((sum - maxs - mins) / n) << endl;
	}
}

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

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

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

void slove(int s){
	vint v(s);
	rep(i, s) scanf("%d", &v[i]);

	sort(all(v));
	ll sum = 0;
	for (int i = 1; i < s - 1; ++i)
	{
		sum += v[i];
	}
	
	printf("%lld\n", sum / (s - 2));
	return;
}

int main(void){

	int s;
	cin >> s;
	while(s != 0){
		slove(s);//???????????°
		cin >> s;
	}

	return 0;
}

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

C++: int main()
{
    int n;
    while(1){
        cin >> x;
        if(x == 0) break;
        int max = -1, mini = 10000, sum = 0, ten = 0, y = 0;
        for(int i = 0; i < x; i++){
            cin >> ten;
            sum += ten;
           
            if(ten < mini) mini = ten;
	    if(ten > max) max = ten;
        }
        sum -= max + mini;
        y = sum / (x - 2);
        cout << y << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
 
int main(){
    int n,i;
    while(cin >> n,n){
        //int point[100]={0,};
		int p;
        int min = 1000;
        int max = 0;
		int total = 0;
        while(n--){
            //cin >> point[i];
			cin >> p;
            //if(point[i] > max) max = point[i];
			if(p > max) max = p;
            //if(point[i] < min) min = point[i];
			//total += point[i];
			if(p < min) min = p;
			total += p;
        }
        cout << (total-max-min)/(n-2) << "\n";
    }

}

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

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

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

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 sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

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

		VI a;
		rep(i, n) {
			int x; cin >> x;
			a.pb(x);
		}
		int min = *min_element(all(a));
		int max = *max_element(all(a));
		int ans = (accumulate(all(a), 0) - min - max) / (n - 2);
		cout << ans << endl;
	}
}

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

int main() {
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    vector<int> score(N);
    for(int i = 0; i < N; i++)
      cin >> score[i];
    sort(score.begin(), score.end());
    cout << accumulate(&score[1], &score[N-1], 0) / (N - 2) << endl;
  }
}

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

int main() {
    int n;

    while (true) {
        cin >> n;
        if (!n) break;
        bool bMax = false;
        bool bMin = false;
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            int t; cin >> t;
            if (bMax == false && t >= 1000) bMax = true;
            else if (bMin == false && t <= 0) bMin = true;
            else sum += t;
        }
        cout << sum/(n-bMax-bMin) << endl;
    }
}