Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

C++: #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	while(1){
		int n;
		cin >> n;
		if(n == 0)
			break;
		
		
		vector <int> s(n);
		int M, m;
		int sum = 0;
		for(int i = 0; i < n; i++){
			cin >> s[i];
			sum += s[i];
			if(i == 0){
				M = s[i];
				m = s[i];
			}
			else{
				M = max(M, s[i]);
				m = min(m, s[i]);
			}
		}
		
		sum -= M + m;
		
		
		cout << sum / (n - 2) << endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    while(true){
        int n;
        cin >> n;
 
        if(n==0)
            break;
 
        int S[100];
 
        int sum = 0;
 
        for(int i=0; i<n; i++){
            cin >> S[i];
            sum += S[i];
        }
 
        sort(S, S+n);
 
        cout << (sum-S[0]-S[n-1])/(n-2) << endl;
    }
 
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int N,sum,mi,ma,a;
	while(cin>>N){
		if(N==0) break;
		sum=0;
		ma=0;
		mi=1001;
		for(int i=0;i<N;i++){
			cin>>a;
			mi=min(mi,a);
			ma=max(ma,a);
			sum=sum+a;
		}
		cout<<(sum-mi-ma)/(N-2)<<endl;
	}
	return 0;
}

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

int main(){
	int n[100];
	int max[2]={0,-1},min[2]={1000,-1},sum=0;
	int m;
	while(true){
		cin>>m;
		if(m==0){
			break;
		}
		max[0]=0;
		max[1]=-1;
		min[0]=1000;
		min[1]=-1;
		sum=0;
		for(int i=0;i<m;i++){
			cin>>n[i];
			if(n[i]>max[0]){
				max[1]=i;
				max[0]=n[i];
			}
			if(n[i]<min[0]){
				min[1]=i;
				min[0]=n[i];
			}
		}
		for(int i=0;i<m;i++){
			if(max[1]!=i && min[1]!=i){
				sum += n[i];
			}
		}
		cout<<sum/(m-2)<<endl;
	}
	return 0;
}

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

int main(void)
{
    int n;
    while (cin >> n && n != 0) {
        int s;
        int max_value = INT_MIN;
        int min_value = INT_MAX;
        int sum = 0;
        for (int i = 0; i < n && cin >> s; i++) {
            max_value = max(max_value, s);
            min_value = min(min_value, s);
            sum += s;
        }
        cout << (sum - max_value - min_value) / (n - 2) << endl;
    }
}

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

using namespace std;

struct CONTEST_DATA{
	int judgements;
	vector< int > points;
};

int main( void ){

	vector< CONTEST_DATA > contests;
	vector< int > answers;

	while( true ){
		CONTEST_DATA cd;
		cin >> cd.judgements;
		if( cd.judgements == 0 ){
			break;
		}
		int point;
		for( int i = 0; i < cd.judgements; i++ ){
			cin >> point;
			cd.points.push_back( point );
		}
		contests.push_back( cd );
	}

	for( int i = 0; i < contests.size(); ++i ){
		sort( contests[ i ].points.begin(), contests[ i ].points.end() );
	}
	for( int i = 0; i < contests.size(); ++i ){
		auto p = contests[i].points.begin();
		contests[ i ].points.erase( p );
		p = contests[ i ].points.end() - 1;
		contests[ i ].points.erase( p );
	}

	for( int i = 0; i < contests.size(); ++i ){
		int answer = 0;
		for( int l = 0; l < contests[ i ].points.size(); ++l ){
			answer += contests[ i ].points[ l ];
		}
		cout << answer / ( contests[ i ].judgements - 2 )<< endl;
	}

	return 0;
}

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

int main()
{
	int n;
	int a[100];
		
	while (1) {
		cin >> n;
		if (n == 0) {
			break;
		}
		int max = 0;
		int min = 1000;
		int total = 0;
		int answer = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			total += a[i];
			if (a[i] > max) {
				max = a[i];
			}
			if (a[i] < min) {
				min = a[i];
			}
		}
		answer = (total - max - min) / (n - 2);
		cout << answer << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	while(true){
	int n; cin >> n;
	if (n == 0) break;
	int ls[1024];
	for (int i = 0; i < n; ++i) {
		cin >> ls[i];
	}
	sort(ls, ls+n);
	long res = 0;
	for (int i = 1; i < n-1; ++i) {
		res += ls[i];
	}
	cout << long(res/(n-2)) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
    int n,s;
    while(cin>>n,n){
        cin>>s;
        int mins=s,maxs=s,sum=s;
        rep(i,n-1){
            cin>>s;
            mins = min(mins,s);
            maxs = max(maxs,s);
            sum += s;
        }
        cout<<(sum-maxs-mins)/(n-2)<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int judge;
int maxscore =0;
int minscore =0;
cin >> judge;
if(judge != 0){
int score[judge];
	for(int i=0; i<judge; i++){
	cin >> score[i];
		if(score[i] > maxscore){
		maxscore = score[i];
		}
		if(score[i] < minscore){
		minscore = score[i];
		}
		if(i==0){
		minscore = score[0];
		}
	}
int lastscore = 0;
for(int j=0;j<judge;j++){
lastscore +=  score[j];
}
lastscore = (lastscore - maxscore - minscore)/(judge - 2);
cout << lastscore <<endl;
}
return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int n, tmp;
  while (cin >> n, n) {
    vector<int> score;
    for (int i = 0; i < n; i++) {
      cin >> tmp;
      score.pb(tmp);
    }
    sort(score.begin(), score.end());
    int sum = 0;
    for (int i = 1; i < n-1; i++) {
      sum += score[i];
    }
    cout << sum/(n-2) << el;
  }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int sum = 0;
		int Max = 0, Min = 1000;
		rep(i, n) {
			int s; cin >> s;
			Max = max(Max, s);
			Min = min(Min, s);
			sum += s;
		}
		cout << (sum - Max - Min) / (n - 2) << endl;
	}
}

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

int main(){
  int n;
  int sum,maxv,minv,tmp;

  while(cin >> n){
    if(n==0)break;
    
    cin >> sum;
    maxv = minv = sum;
    for(int i=0;i<n-1;i++){
      cin >> tmp;
      sum += tmp;
      if(maxv < tmp)maxv = tmp;
      if(minv > tmp)minv = tmp;
    }

    cout << (sum-maxv-minv)/(n-2) << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int num;
while(true)
{
int ans = 0;
cin >> num;
if(num != 0)
{
int a[num];
for(int i = 0;i<num;i++)
{
 cin >> a[i];
}
sort(a, a + num);
for(int i=1; i<num-1;i++)
{
ans += a[i];
}
cout << ans << endl;
}
else
{
return 0;
}
}
}

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

using namespace std;

int main() {
	while(true){
	int n; cin >> n;
	if (n == 0) break;
	int ls[1024];
	for (int i = 0; i < n; ++i) {
		cin >> ls[i];
	}
	sort(ls, ls+n);
	long res = 0;
	for (int i = 1; i < n-1; ++i) {
		res += sort[i];
	}
	cout << long(res/(n-2)) << endl;
	}
	return 0;
}

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

int main(void){
	int judg;
	
	while(1){
		cin >> judg;
		if(judg==0)break;

		//点数入力
		int *score = new int[judg];
		for(int i=0; i<judg; i++)
			cin >> score[i];
		
		//最高点最低点求める
		int max=0,min=0;
		for(int i=0; i<judg; i++){
			if( score[max]<score[i] ) max=i;
			if( score[min]>score[i] ) min=i;
		}
		
		//平均点求める
		int avg=0;
		for(int i=0; i<judg; i++){
			if(i!=max&&i!=min)
				avg+=score[i];
		}
		avg = avg/(judg-2);

		cout << avg << endl;
	}
}

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

using namespace std;

int main()
{
  int n, a[101], t;

  while(cin>>n && n){
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    sort(a, a+n);
    t = 0;
    for(int i = 1; i < n-1; i++){
      t += a[i];
    }

    cout << (t/(n-2)) << endl;
  }

  return 0;
}