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>
#include <ctype.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


int main (){

  while(1){
    vector<int> point;
    int n,i,temp,sum;
    cin >> n;
    if (n==0)break;
    
    for(i=0;i<n;i++){
      cin >> temp;
      point.push_back(temp);
    }
    
    sort(point.begin(),point.end());
    
    sum = 0;
    
    for(i=1;i<n-1;i++){
      sum += point[i];
    }
    
    sum = sum / (n-2);
    
    cout << sum <<endl;
  }
  
  return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)), (x).end())

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 31 - 1;
const int MOD = 1000000007;

void solve(void) {
  while (1) {
    int N;
    scanf("%d\n", &N);
    if (N == 0)
      break;
    vector<int> ps;
    rep(N, i) {
      int p;
      scanf("%d\n", &p);
      ps.pb(p);
    }
    sort(all(ps));
    int ans = ps[0] + ps[N - 1];
    for (int t : ps) {
      if (t != ps[0] && t != ps[N-1]) ans += t;
    }
    printf("%d\n", ans / N);
  }
}

int main(void) {
  solve();
  return 0;
}

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

int main(){
	int n,sum,max,min;
	while(cin>>n&&n>0){
		int S;
		min=1000000000;
		max=0;
		sum=0;
		for(int i=0;i<n;i++){
			cin>>S;
			sum+=S;
			if(min>S){
				min=S;
			}
			if(max<S){
				max=S;
			}
		}
		sum-=(min+max);
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define INF 1145141919810893931
using namespace std;

int main() {
	ll n; cin >> n;
	while (n) {
		vector<ll> a(n);
		vector<ll> b(n - 2);
		rep(i, n) cin >> a[i];
		sort(a.begin(), a.end());
		ll b_count = 0;
		nrep(i, 1, n - 1) b[b_count++] = a[i];
		ll sum = 0;
		rep(i, b.size()) sum += b[i];
		cout << sum / b.size() << endl;
		cin >> n;
	}
	return 0;
}

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

int main()
{
	int x[20], y, i, j, n, sum = 0;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> x[i];
		sum += x[i];
	}
	sort(x,x+n);

	cout << (sum-x[0]-x[n-1]) / (n - 2);
	return 0;
}

C++: #include <stdio.h>
#include <float.h> 
int main(void){	
  int n[100];	
  int a[1000];	
  int i,j,max[100],min[100],suma[100],sumb[100],ave[100]; 
  for(i = 0;;i++){  
    scanf("%d",&n[i]);
    if(n[i]==0)break;  
    for(j=0 ; j<n[i] ;j++){ 
      scanf("%d",&a[j]);
    } 
    max[i] = a[0];
    min[i] = a[0];
    suma[i] = 0; 
    for(j=0 ; j<n[i] ; j++){
      if(a[j] >= max[i]){
	max[i] = a[j];
      }
      if(a[j] <= min[i]){
	min[i] = a[j];
      }
      suma[i] += a[j];
    }
  } 

  for(j = 0;j < i;j++){
    sumb[j] = suma[j]-max[j]-min[j]; 
    n[j] -= 2;
    ave[j] = sumb[j] / n[j] ;
    printf("%d\n",ave[j]);    
  }
  return 0;
  
}

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

int main()
{
	int n,m;
	int ave[1000]={0};

	m=0;
	while(1){
		int point[100]={0};
		int min=1000;
		int max=0;
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin>>point[i];
			if(point[i]>max) max=point[i];
			if(point[i]<min) min=point[i];
			ave[m]++;
		}
		ave[m]=(ave[m]-max-min)/(n-2);
	m++;
	}
	for(i=0;i<m;i++){
		cout<<ave[i]<<endl;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    while(cin>>n and n){
        int a[n]={};
        int max=-5,min=10000,sum=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            if(a[i]<min){
                min=a[i];
            }
            if(a[i]>max){
                max=a[i];
            }
            sum+=a[i];
        }
        int ave=(sum-max-min)/(n-2);
        cout<<ave<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
    int N,input;
    while (1){
        cin >> N;
        if (N==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<N;i++) {
            cin >> input;
            sum = sum+input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        printf("%d\n", (sum-max-min)/(N-2));
    }
}

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

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	while(cin>>n,n!=0){
		vector<int> a(n);
		rep(i,n)cin>>a[i];
		cout<<(accumulate(all(a),0)-*max_element(all(a))-*min_element(all(a)))/(n-2)<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
        int n, s ;
	while (cin >> n && n > 0){
		int large = 0;
		int small = 1000;
		int sum = 0;
  		for (int i=0; i>n; ++i){
			cin >> s;
			sum = sum + s;
			if (large < s) {large = s};
			if (small > s) {small = s};
		};
		int ans = 0;
		ans = (sum - large - small) / (n - 2);
		cout << ans << endl ;
	};
}

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


int main()
{
	int n;
	int point[100];
	while (cin >> n)
	{
		if (n == 0)break;
		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			cin >> point[i];
		}

		sort(point,point + n);

		for (int i = 1; i < n - 1; i++)
		{
			sum += point[i];
		}

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

C++: #include <iostream>
using namespace std;
#define NUMBER 20
int main(void)
{
	int j = 0;
	while (j < NUMBER){

		int h,i, n, b;
		int a[100];

		cin >> n;

		if (n == 0)
			break;

		for (i = 0; i < n; i++)
			cin >> a[i];

		for (i = 0; i < n-1; i++) {
			for (h = 1; h < n; h++) {
				if (a[i] > a[h]) {
					b = a[i];
					a[i] = a[h];
					a[h] = b;
				}
			}
		}
		
		b = 0;

		for (i = 1; i < (n - 1) ; i++)
			b = b + a[i];

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

		j++;
	}
	return 0;
}