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 N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<N; ++j){
    Max=A[0];
	if(A[j]>Max) Max=A[j];
    }
  for (int k=0; k<N; ++k){
    Min=A[0];
	if(A[k]<Min) Min=A[k];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
  Sum=0;
  Max=0;
  Min=0;
 }
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n;
string s[155];
bool up=false;

void init(){
  rep(i,105)s[i]="aaa";
}

int main(){
  int n;
  int data[105];
  while(cin>>n){
    if(n==0)break;
    rep(i,n)cin>>data[i];
    sort(data,data+n);
    ll sum=0;
    for(int i=1;i<n-1;i++)sum+=data[i];
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

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

    int n;
    while (cin >> n, n) {
        vector<int> v(n);
        rep(i, n) cin >> v[i];
        sort(all(v));
        cout << accumulate(v.begin() + 1, v.end() - 1, 0) / (n - 2) << endl;
    }
}

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

int a[1001];
int main(){
	int n, sum;
	while(cin >> n, n){
		sum = 0;
		for(int i = 0;i < n;i++){
			cin >> a[i];
			sum += a[i];
		}
		sum -= *max_element(a, a+n);
		sum -= *min_element(a, a+n);
		cout << sum/(n-2) << endl;
	}
	return 0;
}

C++: #include <iostream>

int main() {
	while (1) {
		int N;
		int s[100];
		std::cin >> N;
		if ( N == 0 ) break;
		for ( int i=0; i<N; i++ ) {
			std::cin >> s[i];
		}
		int min=s[0], max=s[0], sum=0;
		for ( int i=0; i<N; i++ ) {
			if ( min > s[i] ) min = s[i];
			if ( max < s[i] ) max = s[i];
			sum += s[i];
		}
		std::cout << (int)((sum-min-max)/(N-2)) << std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	while(true){
		int score;
		int n;
		int maxs,mins;
		cin>>n;
		if(n==0)break;
		vector<int> s(n);
		for(int i=0;i<n;i++){
			cin>>s[i];
		}
		maxs=*max_element(s.begin(),s.end());
		mins=*min_element(s.begin(),s.end());
		for(int i=0;i<n;i++){
			score+=s[i];
		}
		cout<<(score-maxs-mins)/(n-2)<<endl;
	}
}

C++: // AOJ 1147
#include<iostream>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main() {
  int n;
  while (cin >> n and n) {
    int sum = 0, mxm = -1e5, mnm = 1e5;
    REP(i, n) {
      int s;
      cin >> s;
   
      if (mxm < s) mxm = s;
      if (mnm > s) mnm = s;
   
      sum += s;
    }
   
    cout << (sum - mxm - mnm) / (n - 2) << endl;
  }
}

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

using namespace std;

int main() {
	int n;
	while (cin >> n && n != 0) {
		vector<int> s(n);
		for (int i = 0; i < n; ++i) cin >> s[i];

		sort(s.begin(), s.end());
		int ave = 0;
		for (int i = 1; i < n - 1; ++i) ave += s[i];
		ave /= (n - 2);
		cout << ave << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#define S 20

int main(void)
{
	int a[S];
	int i;
	int n,max,min,sum=0;
	
	for(;;)
	{
		max=0, min=1000,sum=0;
		
		scanf("%d",&n);
		if(n==0) break;
		
		for(i=0; i<n; i++)
		{
			scanf("%d",&a[i]);
		}
		
		for(i=0; i<n; i++)
		{
			if(max<a[i]) max=a[i];
			if(min>a[i]) min=a[i];
		}
		
		for(i=0; i<n; i++)
		{
			sum+=a[i];
		}
		
		sum=sum-max-min;
		printf("%d\n",sum/(n-2));
	}
	
	return 0;
}

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

using namespace std;

int main(){
	int n;

	cin >> n;

	while(n != 0){
		int point[1005];
		int max = 0, min = 0;

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

		for(int i=1; i<n; i++){
			if(point[max] < point[i])
				max = i;
			else if(point[i] < point[min] )
				min = i;
		}

		point[max] = 0;
		point[min] = 0;

		int sum = 0;

		for(int i=0; i<n; i++)
			sum += point[i];

		//cout << sum << endl;

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

		cin >> n;
	}

	return 0;
}

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

int main(){
	int n;
	cin>>n;
	vector<int> d(n);
	for(int i=0;i<n;i++)
		cin>>d[i];
	for(int i=0;i<10000;i++){
		bool isok=true;
		if(i<10){
			for(int j=0;j<n;j++)
				if(d[j]==i){
					isok=false;
					break;
					
				}
			if(!isok) continue;
			cout<<i<<endl;
			return 0;

		}
		else if(i<100){
			for(int j=0;j<n-1;j++)
				if(d[j]==i/10 && d[j+1]==i%10){
					isok=false;
					break;
				}
				if(!isok) continue;
				cout<<i<<endl;
				return 0;

			}
		else if(i<1000){
			for(int j=0;j<n-2;j++)
				if(d[j]==i/100 && d[j+1]==(i/10)%10&&d[j+2]==i%10){
					isok=false;
					break;
				}
				if(!isok)	continue;
				cout<<i<<endl;
				return 0;
			}
		else
			for(int j=0;j<n-3;j++){
				if(d[j]==i/1000 &&d[j+1]==(i/100)%10 &&d[j+2]==(i/10)%10 && d[j+3]==i%10){
					isok=false;
					break;
				}
				if(!isok) continue;
				cout<<i<<endl;
				return 0;
			}


	}


}

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

using namespace std;

int main() {
	int n;
	int judge[100];
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> judge[i];
		}
		for (int i = n; i > 1; i--) {
			for (int j = 0; j < i-1; j++) {
				if (judge[j] > judge[j+1]) {
					swap(judge[j], judge[j+1]);
				}
			}
		}
		for (int i = 1; i < n-1; i++) {
			sum += judge[i];
		}
		cout << sum/(n-2) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  
  int n,score[100],sum;
  
  while(1){
    
    cin >>n;
    
    if(n == 0)break;

    sum=0;
    
    for(int i=0 ; i < n ; i++)cin >>score[i];
    
    sort(score,score+n);
    
    for(int i=1 ; i < n-1 ; i++)sum+=score[i];
    
    cout <<sum/(n-2)<<endl;
    
  }
  
  return 0;
}