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 <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <bitset>
#include <tuple>

using namespace std;

int main(void)
{
  while (true) {

    int n;
    cin >> n;
    if (n == 0) break;
    int p[n];
    for (int i = 0; i < n; i++)
      cin >> p[i];
    int top,bottom,sum;
    top = -1;
    bottom = 1001;
    sum = 0;
    for (int i = 0; i < n; i++) {
      if (top < p[i])
	top = p[i];
      if (bottom > p[i])
	bottom = p[i];
    }
    
    bool t, b;
    t = b = true;
    for (int i = 0; i < n; i++) {
      if (top == p[i] && t) {
	t = false;
      }
      else if (bottom == p[i] && b) {
	b = false;
      }
      else
	sum+=p[i];
    }
int ans = sum/(n-2);
    cout << ans << endl;
    
  }
  return 0;	
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  s++;
  cin >> N;
  for(ll i = 0; i < N; ++i;){
      cin >> s[i];
  }
  sort(s,s+N);
  for(ll i = 1; i < N-1; ++i){
    sum+=s[i];
  }
  cout<<sum/(N-2)<<endl;
}
}

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

int main(void){
	int n;
	int *tokuten;
	int maxi=0,mini=1000;
	int goukei=0,cnt=0;
	int *heikin=new int[100];
	while(1){
		cin>>n;
		int i=0;
		if(n==0)
			break;

		tokuten=new int[n];
		maxi=0;
		mini=1000;
		for(i=0;i<n;i++){
			cin>>tokuten[i];
			maxi=max(maxi,tokuten[i]);
			mini=min(mini,tokuten[i]);
			goukei+=tokuten[i];
		}
		
		
		goukei=goukei-(mini+maxi);
		goukei=goukei/(n-2);
		heikin[cnt]=goukei;
		goukei=0;
		cnt++;
		delete[] tokuten;
		
	}
	for(int j=0;j<cnt;j++)
		cout<<heikin[j]<<endl;
	delete[] heikin;
	
	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;
        for(int i=0;i<n;i++){
            //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>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    while(1) {
        cin >> n;
        if (n == 0) return 0;
        vector <int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        int sum = 0;
        for (int i = 1; i < n-1; i++) {
            sum += a[i];
        }
        cout << (int)sum/(a.size()-2) << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while (true) {
        int s;
        cin >> s;
        if (s == 0)
            return 0;
        int tot = 0;
        int nax = -1, nin = 10000;
        for (int i = 0; i < s; ++i) {
            int x;
            cin >> x;
            chmax(nax, x);
            chmin(nin, x);
            tot += x;
        }
        cout << (tot - nax - nin) / (s - 2) << "\n";
    }
    return 0;
}

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

int main()
{
    int n,s;
    int sum = 0;
    std::vector<int> v;
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> s;
        v.push_back(s);
    }

    sort(v.begin(),v.end());

    for(int i = 1; i < v.size() -1 ; i++)
    {
        sum += v[i];
    }
    int ave = sum / (v.size() - 2);
    cout << ave <<endl;
    return 0;
}

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

int main(){
  int n,s;
  vector<int> ss;
  while(1){
    cin>>n;
    //    cout<<"::"<<n<<endl;
    if(n==0)break;
    ss.clear();
    int i,j,k;
    for(i=0;i<n;i++){
      cin>>s;
      ss.push_back(s);
    }
    sort(ss.begin(),ss.end());
    int re=0;
    for(i=1;i<ss.size()-1;i++)
      re+=ss[i];
    re/=ss.size()-2;
    cout<<re<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int n,a[100],s;
    while(cin >> n,n){
        s = 0;
        for(int i = 0;i < n;++i){
            cin >> a[i];
        }
        sort(a,a+n);
        for(int i = 1;i < n-1;++i){
            s += a[i];
        }
        cout << s/(n-2) << endl;
    }
    return 0;
}

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

int n, a[110];

int main(){
	while(cin >> n && n > 0){
		int mins = 1010;
		int maxs = 0;
		int sum = 0;
		for(int i=0; i<n; ++i){
			cin >> a[i];
			mins = min(mins, a[i]);
			maxs = max(maxs, a[i]);
			sum += a[i];
		}
		int ans = (sum - mins - maxs) / (n-2);
		cout << ans << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	int n;
	int s[1000];
	while(cin >> n && n>0){
		for(int i=0; i<n; i++){
			cin >> s[i];
		}
		sort(s, s+n);
		int sum = 0;
		for(int i=1; i<n-1; i++){
			sum += s[i];
		}
		cout << sum/(n-2) << endl;
	}
        return 0;
}

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

int main() {
	int n;
	while (cin >> n) {
		if (!n)break;
		int _max = 0, _min = 1001, s, ans = 0, i = 0;
		for (i; i < n; ++i) {
			cin >> s;
			ans += s;
			_max = max(_max, s);
			_min = min(_min, s);

		}
		ans -= _max + _min;
		ans = int(ans / (n - 2));
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int n;
	int data[128];
	while(scanf("%d",&n),n){
		rep(i,n)scanf("%d",data+i);
		sort(data,data+n);
		int sum = 0;
		REP(i,1,n-1)sum+=data[i];
		printf("%d\n",sum/(n-2));
	}
	return 0;
}