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>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n;
int a[110];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

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

  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;
 
int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int max = -1, min = 10000, sum = 0, score = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> score;
            sum += score;
            if(score > max) max = score;
            if(score < min) min = score;
            cout << max << ' ' << min << endl;
        }
        sum -= max + min;
        ans = sum / (n - 2);
        cout << ans << endl;
    }
    return 0;
}

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

int main(void){
     int n;
     int s[103];
     while(cin >> n && n != 0){
	     for(int i=0; i<n;i++){
	     	cin >> s[i];
	     }
	     sort(s, s+n);
	     long long 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(){
  while(1){
        int n,sum=0,ans=0,max=0,min=1001;
        cin >> n;
        if(n==0) break;
        int s[n];
        for(int i=0; i<n; i++){
          cin >> s[i];
          sum += s[i];
        }
        for(int i=0; i<n; i++){
          if(s[i] > max) max = s[i];
          if(s[i] < min) min =s[i];
        }
        sum = sum -max -min;
        ans = sum/(n-2);
        cout << ans << endl;
  }
  return 0;
}

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


int main(){
	int num = 0;
	while (cin >> num){
		if (num == 0)return;
		vector<int> vec;
		int temp;
		while (cin >> temp){
			vec.push_back(temp);
		}
		sort(vec.begin(),vec.end());
		vec.pop_back();
		reverse(vec.begin(), vec.end());
		vec.pop_back();
		int ave = 0;
		for (int i = 0; i < vec.size(); i++)
			ave += vec[i];
		ave /= vec.size();
		cout << ave << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

int main(){
  while(1){
    cin >> n;
    if(!n)break;
    rep(i,0,n)cin >> d[i];
    sort(d,d+n);
    l = 0;
    rep(i,1,n-1)l += d[i];
    print(l / (n-2));
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;




int main(){
	int n;
	vi v;
	while(cin>>n){
		if(n==0)break;
		v.clear();
		rep(i,n){
			int a;
			cin>>a;
			v.pb(a);
		}
		sort(all(v));
		int sum=0;
		repc(i,1,n-1){
			sum+=v[i];
		}
		//cout<<sum<<" "<<n-2<<endl;
		cout<<(int)sum/(n-2)<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    while(cin>>n){
        if(n==0)return 0;
        vector<int> v(n,0);
        for(int &e:v){
            cin>>e;
        }
        sort(v.begin(),v.end());
        cout<<accumulate(v.begin()+1,v.end()-1,0)/(n-2)<<endl;
    }
    return 0;
}

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

const int MAX_N = 100;

int main() {
	int n,x;
	int score[MAX_N];

	while(cin >> n) {
		if(n == 0) return 0;

		int max = -1,max_i,min = 1001,min_i;
		for(int i = 0;i < n;i++) {
			cin >> x;
			score[i] = x;

			if(max < x) {
				max = x;
				max_i = i;
			}

			if(min > x) {
				min = x;
				min_i = i;
			}
		}

		//??¨??????????????°
		if(max_i == min_i) {
			cout << max << endl;
			continue;
		}

		int total = 0;
		for(int i = 0;i < n;i++) {
			if(i != max_i && i != min_i) total += score[i];
		}

		cout << total / (n - 2) << endl;
	}
}

C++: #include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
    int n;
    while (cin>>n,n) {
        vector<ll> a(n);
        rep(i,n) cin>>a[i];
        sort(a.begin(),a.end());
        a.pop_back();
        sort(a.begin(),a.end(),greater<>());
        a.pop_back();
        ll sum = 0;
        rep(i,n-2) sum+=a[i];
        ll ans=sum/(n-2);
        cout<<ans<<endl;
    }
}