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>

using namespace std;



int main(){

	while(true){
		int n;
		cin>>n;

		if(n==0) break;

		int max=0;
		int min=1000;
		int sum=0;
		for (int i = 0; i < n; ++i)
		{
			int current;
			cin>>current;
			if(current>max){
				max=current;
			}
			if(current<min){
				min=current;
			}
			sum+=current;
		}

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

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-1); ++j){
    Max=A[0];
	if(A[j+1]>A[j]) Max=A[j+1];
    }
  for (int k=0; k<(N-1); ++k){
    Min=A[0];
	if(A[k+1]<A[k]) Min=A[k+1];
	}
  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 <cstdio>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int n;
int s[1000];

int main(){
	while(scanf("%d", &n), n){
		rep(i, n){
			scanf("%d", &s[i]);
		}
		int t = 0;
		rep(i, n){
			t += s[i];
		}
		int a = *min_element(s, s + n);
		int b = *max_element(s, s + n);
		printf("%d\n", (t - a - b) / (n - 2));
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        int sum = 0;
        int max = 0;
        int min = 100000;
        for (int i = 0; i < n; ++i) {
            int a;
            cin >> a;
            sum += a;
            if (max < a) max = a;
            if (min > a) min = a;
        }
        sum -= min + max;
        cout << sum / (n - 2) << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int MIN,MAX,n,sum,a,i;
int main(){
while(true){
cin>>n;if(!n){break;}
MIN=10000000;
MAX=0;sum=0;
for(i=0;i<n;i++){cin>>a;MIN=min(MIN,a);MAX=max(MAX,a);sum+=a;}
cout<<(sum-MIN-MAX)/n<<endl;
}
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n1;
	cin >> n1;
	while (n1 > 0){
		int a[100000] = { 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, s;
    while (cin >> n) {
        int mins = 1000, maxs = 0, sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> s;
            sum += s;
            mins = min(s, mins);
            maxs = max(s, maxs);
        }
        sum -= mins + maxs;
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	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>
using namespace std;

int main()
{
	int n,m,i;
	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(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() {
    vector<int> sss(20);
    for (int l=0;l<20;l++){

int A;
cin >>A;
 if (A==0){
        break;
    }
int cnt=0;
vector<int> vec(A);
for (int i=0;i<A;i++){
    cin >> vec[i];
    cnt+=vec[i];
}
sort(vec.begin(),vec.end());

cout << ((cnt-(vec[0]+vec[A-1]))/(A-2))<<endl;
   
    }
}

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

int main() {
	int n, s;
	int  i;
	int max, min;
	int sum;
	int avg;
	while(cin >> n, n != 0) {
		sum = max = 0;
		min = 11111;
		for(i=0;i<n;i++) {
			cin >> s;
			max = (s > max)?s:max;
			min = (s < min)?s:min;
			sum += s;
		}
		avg = (sum-max-min)/(n-2);
		cout << avg << endl;
	}
	return 0;
}

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

int main(void){
	bool isPrime[10010];
	std::vector<int> prime,input;
	int i,j,k,ans;

	for(bool b : isPrime) b=true;
	for(i=2;i<10010;++i){
		for(j=i*2;j<10010;j+=i) isPrime[j]=false;
	}
	for(i=2;i<10010;++i){
		if(isPrime[i]) prime.push_back(i);
	}

	while(true){
		std::cin >> i;
		if(i==0) break;
		input.push_back(i);
	}

	for(int in : input){
		ans=0;
		for(i=0;true;++i){
			if(prime[i]>in) break;
			k=in;
			for(j=i;true;++j){
				k-=prime[j];
				if(k<0) break;
				if(k==0) ++ans;
			}
		}
		std::cout << ans << std::endl;
	}
	return 0;
}

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

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0 ;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int sum=0;
    for (int i=0;i<n-1;i++){
        sum+=a[i];
    }
    cout << (float) sum /(float) (n-2)<<endl;
}

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

int s;
int n,maxn,minn,sum;
int main(){
	while(1){
		cin >> n;
		if(n==0)break;
		minn=1001;
		maxn=0;
		sum=0;
		for(int i=0;i<n;i++){
			cin >>s;
			sum+=s;
			if(maxn<s)maxn=s;
			if(minn>s)minn=s;
		}
		sum=sum-minn-maxn;
		cout <<sum/(n-2)<<endl;

	}
	return 0;
}

C++: #include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"

using namespace std;
#define rep(p,q) for(int i = p;i < q;i++)

//ICPC Score Totalizer Software
int main(void) {
	int num = 0;
	while (cin >> num && num != 0) {
		vector<int> v = vector<int>();
		int point = 0;
		rep(0, num) {
			cin >> point;
			v.push_back(point);
		}
		sort(v.begin(), v.end());
		int sum = 0;
		rep(1, num - 1) {
			sum += v[i];
		}
		cout << sum / (num - 2) << endl;
	}
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    int n;
    int tmp, sum;
    vector<int> s;

    while(true) {
        cin >> n;
        if(n == 0) return 0;
        sum = 0;
        s.clear();
        for(int i = 0; i < n; i++) {
            cin >> tmp;
            s.push_back(tmp);
        }

        sort(s.begin(), s.end());
        for(int i = 1; i < n-1; i++){
            sum += s[i];
        }
        cout << floor(sum * 1.0 / (n-2)) << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N,S,sum,mx,mn;
    while(cin >> N && N>0)
    {
        sum = 0;
        mx = -1;
        mn = 1001; 
        for(int i=0; i<N; ++i)
        {
            cin >> S;
            sum += S;
            mx = max(S,mx);
            mn = min(S,mn);
        }
        cout << (sum - mx - mn) / (N - 2) << endl;
    }
}