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>
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 <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define prime first
#define weight second
#define MP make_pair
#define PB push_back

using namespace std;

int main(){
	int n = 0;
	while(cin >> n && n != 0){
		map<int, int> ev;
		int max = -1, min = 1001;
		rep(i, n){
			int s = 0;
			cin >> s;

			if(s > max) max = s;
			else if(s < min) min = s;

			if(ev.find(s) != ev.end()) ev[s]++;
			else ev[s] = 1;
		}

		ev[max]--;
		ev[min]--;

		int result = 0, factor = 0;
		for(map<int, int>::iterator it = ev.begin(); it != ev.end(); it++){
			for(int i = 0; i < it->second; i++){
				result += it->first;
				factor++;
			}
		}

		cout << result / factor << endl;
	}
	

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
    int N, arr[100];
    while(scanf("%d", &N) != EOF && N != 0){
        for(int i = 0; i < N; i++){
            scanf("%d", arr+i);
        }
        sort(arr, arr + N);
        int s = 0;
        for(int i = 1; i < N-1; i++){
            s += arr[i]; 
        }
        printf("%d\n", s / (N-2));
    }
    return 0; 
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n1;
	cin >> n1;
		int a[n1] = { 0 };
		for (int i = 0; i < n1; i++){
			cin >> a[i];
		}
		sort(a, a + n1);
		a[0] = { 0 };
		a[n1 - 1] = { 0 };
		for (int i2 = 1; i2 < n1; i2++){
			a[0] += a[i2];
		}
		cout << a[0] / (n1 - 2) << endl;
return 0;
		
}

C++: #include <iostream>

using namespace std;

int main(){
    int n, max = 0, min = 10000, sum = 0;
    while(cin >> n && n > 0){
        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];
        }
        for (int i = 0; i < n; i++){
            if (s[i] < min)
                min = s[i];
        }
        cout << (sum - max - min)/(n - 2) << endl;
    }
}

C++: #include <iostream>

int main()
{
    int judgeNum;
    int maxPoint = 0;
    int minimumPoint = 0;
    int pointSum = 0;

    std::cin >> judgeNum;

    int point[judgeNum];

    for(int i = 0; i < judgeNum; i++) {
        std::cin >> point[i];
        if(point[i] > maxPoint) {
            maxPoint = point[i];
        } else if (point[i] < minimumPoint) {
            minimumPoint = point[i];
        }
        pointSum += point[i];
    }

    std::cout << (pointSum - maxPoint - minimumPoint) / (judgeNum - 2) << std::endl;

    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int n, ma, mi, sum, k;
  while(cin >> n, n){
    sum = ma = 0; mi = 9999;
    for(int i = 0;i < n; i++){
      cin >> k;
      sum += k;
      ma = max(ma, k); mi = min(mi, k);
    }
    sum = sum - ma - mi;
    cout << sum / (n - 2) << endl;
  }
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int n, s[100], k;
	double l, g, sum;
	double ans;
	while(1){
		cin >> n;
		if(!n) break;
		g = -1;
		l = 1001;
		sum = 0;
		for(k=0;k<n;k++){
			cin >> s[k];
			sum += s[k];
			if(g < s[k]) g = s[k];
			if(l > s[k]) l = s[k];
			//cout << g << " " << l << " " << sum << endl;
		}
		ans = (sum - l - g)/((double)n-2);
		cout << (int)ans << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int N;
        cin >> N;
        if(N==0) break;
        vector<int> A(N,0);
        for(int i=0;i<N;i++){
            cin >> A[i];
        }
        int M=0;
        int m=1000;
        int sum=0;
        for(int i=0;i<N;i++){
            sum+=A[i];
            if(M<A[i]){M=A[i];}
            if(m>A[i]){m=A[i];}
        }
        cout << (sum-M-m)/(N-2) << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
 
cin>>n;
vector<int> v(n);
int sum=0;
 for(int i=0;i<n;++i){
cin>>v[i];
}
sort(begin(v),end(v));
for(int i=1;i<n-1;++i){
sum+=v[i];}
cout<<sum/(n-2)<<endl;
}

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int sum=0,mx=-1,mn=1001;
		for(int i=0;i<n;i++){
			int a;	scanf("%d",&a);
			sum+=a;
			mx=max(mx,a);
			mn=min(mn,a);
		}
		printf("%d\n",(sum-mx-mn)/(n-2));
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int n;
long int ans;
int main() {
  for(;;) {
    scanf("%d", &n);
    if(n == 0) break;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) scanf("%d", &v[i]);
    sort(begin(v), end(v));
    v[n - 1] = 0, v[0] = 0;
    for(int i = 0; i < n; ++i) ans+=v[i];
    ans /= n - 2;
    printf("%ld\n", ans);
    n = 0, ans = 0;
    v.clear();
  }
  return 0;
}

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