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>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
if(judge != 0){
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

C++: #pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

signed main(void)
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);

    while(true){
        int N;
        cin>>N;
        if(N==0) return 0;
        vector<int> V(N);
        for(int i=0;i<N;i++) cin>>V[i];
        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;

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

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

C++: #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
cin>>N;
  while(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;
  cin>>N;
  }
}
}

C++: # include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

  while (cin >> n) {
    if (!n) break;

    vector<int> scr(n);
    for (int i=0; i<n; i++) {
      cin >> scr[i];
    }

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

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

  return 0;
}

C++: #include <stdio.h>
#include <algorithm>

int main() {
	int a[100];
	int n, s, i, j, sum;

	scanf("%d",&n);

	while(true) {
		sum = 0;
		if(n == 0)break;
		for(i = 0; i < 100; i++) {
			a[i] = 1000;
		}	
		for(i = 0; i < n; i++) {
			scanf("%d",&s);
			a[i] = s;
		}
		std::sort(a,a+100);
		for(j = 1; j < n-1; j++) {
			sum = sum + a[j];
		}
		printf("%d\n",sum/(n-2));
		scanf("%d",&n);
	}
	return 0;
}

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

int main(){
        int i = 0;
        
        while(cin >> i && !(i == 0)){
                int a[i];
                int j = 0;              

                for(j=0; j<i; j++){
                        cin >> a[j];
                }
                cout << endl;           
        
                //sum
                int sum = 0;
                for (j=0; j<i; j++) {
                        sum += a[j];
                }
        
                //largest,smallest
                int largest = 0;
                int smallest = 1000;
                for (j=0; j<i; j++){
                        if (a[j] > largest)
                                largest = a[j];
                        else if (a[j] < smallest)
                                smallest = a[j];
                }
                
                //average
                int average = 0;
                average = (sum - largest - smallest) / (i - 2);
                cout << average;
        }

C++: #include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    int n;
    while( true ){
        cin >> n;
        if (n == 0) break;
        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;
    }   
    return 0; 
}

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

int main()
{
	int n;

	while(true){
		std::cin >> n;
		if ( n == 0 ) break;

		std::vector<int> v(n,0);

		for ( int i = 0; i < n; ++i ) {
			std::cin >> v[i];
		}

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

		int sum = 0;
		for ( int i = 1; i < n-1; ++i ) {
			sum += v[i];
		}
		std::cout << sum / (n-2) << std::endl;
	}
	return 0;
}

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

int main(){
    int n,s,avg;
    while (cin>>n && n!=0){
        int sum=0,ma=0,mi=1000;
        for (int i=0;i<n;i++){
            cin>>s;
            sum+=s;
            ma=max(ma,s); //最大値の更新
            mi=min(mi,s); //最小値の更新
        }
        avg=(sum-ma-mi)/(n-2); //平均の計算
        cout<<avg<<endl;
    }
}

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

using namespace std;

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0)return 0;
		int b[100];
		for (int i = 0; i < n; i++)cin >> b[i];
		sort(b, b + n);
		int res = 0;
		for (int i = 1; i < n - 1; i++)res += b[i];
		cout << res/(n-2) << endl;
	}
}

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

const int LLINF = 1LL << 60;


signed main()
{
  int N;

  while(cin >> N, N) {
    int maxv = -LLINF, minv = LLINF;
    int sum = 0, A;
    Rep(i, N) {
      cin >> A; sum += A;
      maxv = max(maxv, A), minv = min(minv, A);
    }

    sum -= maxv + minv;

    cout << sum / (N - 2) << endl;
    
  }

  return 0;
}