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<stdio.h>
using namespace std;
int main(void){
    int n;
    int x[21];
    while(1){
        int S=0;
        cin>>n;
        if(n==0){
            break;
        }
        for(int i=0;i<n;i++){
            cin>>x[i];
        }    
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(x[i] < x[j]){
                    int temp = x[i];
                    x[i] = x[j];
                    x[j] = temp;
                }
            }
        }
        for(int i=1;i<n-1;i++){
            S=S+x[i];
        }
        int A=0;
        A=S/(n-2);
        cout<<A<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n==0) break;
    vector<int> v(n);
    for(int i=0; i<n; i++){
      cin >> v[i];
    }
    sort(v.begin(),v.end());
    int ret = 0;
    for(int i=1; i<v.size()-1; i++){
      ret += v[i];
    }
    ret /= n-2;
    cout << ret << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0)
		break;
		int x[n],ma=0,mi=0,ans=0;
		for(int i=0;i<n;i++){
			cin>>x[i];
			ans+=x[i];
			if(i==0)
			mi=x[i];
			ma=max(x[i],ma);
			mi=min(x[i],mi);
		}
		cout<<(ans-(ma+mi))/(n-2)<<endl;
	}
return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define LOOP(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) LOOP(i, 0, n)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359

int main(void) {
  int cnt = 0;
  vector<int> ans;
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    vector<int> v;
    int temp;
    for (int i = 0; i < n; i++) {
      cin >> temp;
      v.push_back(temp);
    }
    sort(v.begin(), v.end());
    for(int i=1; i<n-1; i++) {
      cnt += v[i];
    }
    ans.push_back(cnt/(n-2));
    cnt = 0;
  }

  for(int i=0; i<ans.size(); i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

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

int main(){
	int N,n,sum;
	vector<int> point;
	while(1){
		cin>>N;
		if(N==0) break;
		sum=0;

		while(!point.empty()){
			point.pop_back();
		}

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

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

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

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

int main() {
	while (1) {
		int n, maxn, minn;
		int pn = 0;
		cin >> n;
		if ( n == 0 ) break;
		int s[n];
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			if ( i == 0 ) {
				maxn = s[0];
				minn = s[0];
			} else {
				if ( s[i] > maxn ) maxn = s[i];
				if ( s[i] < minn ) minn = s[i];
			}
			pn += s[i];
		}
		cout << (pn - maxn - minn) / (n - 2);
	}
	return 0;
}

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

int main(){
	int n;

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

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

  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<utility>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    
    cin.tie( 0 );
    ios::sync_with_stdio( false );
    
    while(true){
        int n;
        cin >> n;
        
        if(n == 0){ break; }
        vector<int> vc(n);
        
        for(int i=0; i<n; i++){
            cin >> vc[i];
        }
        sort(vc.begin(), vc.end());
        auto res = (accumulate(vc.begin() + 1, vc.end() -1, 0));
        cout << res / (n-2) << endl;
    }
    return 0;
}

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

int main()
{
	int N, n, sum, largest, smallest;
	sum  = 0; largest = 0; smallest = 1000;
	
	while(cin >> N; && N>0){
		for(int i = 0; i<N; i++)
		{
			cin >> n;
			sum += n;
			
			if(smallest > n){ smallest = n;}
			if(largest < n){ largest = n;}
		}
	
		cout << (sum-smallest-largest)/(N-2) << endl;
	}
}

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

using namespace std;

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

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

int main(){
  int n,a[21],b[21];
  while(1){
    
    cin>>n;
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    
    int max=0,min=10001;
    for(int i=0;i<n;i++){
      if(max<a[i]){
	max=a[i];
      }
      if(min>a[i]){
	min=a[i];
      }
    }
    
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=a[i];
    }
    sum-=(max+min);
    
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

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

int main() {
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		vector<int>s(a);
		int m = 0;
		for (int b = 0; b < a; b++) {
			int d;
			cin >> d;
			s[b] = d;
			m += d;
		}
		sort(s.begin(), s.end());
		cout << (m - s[0] - s[s.size() - 1]) / (a-2) << endl;
	}
}

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

using namespace std;

int main(){
	vector<int> array;
	int i,x,max,min,sum,n;
	max = 0;
	min = 1000;

	while(cin>>n){
	array.clear();
	sum=0;

	for(i=0;i<n;i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<n;i++){
		sum += array[i];
	}
	sum = sum-max-min;
	cout << sum/n << endl; 
	}

}