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 <bits/stdc++.h>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	while (1) {
		int n;
		int s[101];
		int mini = INF;
		int maxi = -1;
		int total = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		FOR(i, 1, n) {
			cin >> s[i];
			if (maxi < s[i]) {
				maxi = s[i];
			}
			else if (mini > s[i]) {
				mini = s[i];
			}
			else {
				total += s[i];
			}
		}
		cout << total / (n - 2) << endl;
	}


}

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

#define ll long long int
#define ld long long double
#define reps(i,f,n) for(int i=f;i<n;i++)
#define rep(i,n) reps(i,0,n)
#define m1 cout<<"move1"<<endl
#define m2 cout<<"move2"<<endl
#define m3 cout<<"move3"<<endl
#define m4 cout<<"move4"<<endl

int main(){
  ll sum=0;
  int N=0;
  int max_v= -1;
  int min_v= 10000;
  int a;
  int b;
  // m2;
  while(cin>>a){
    N = a;
    // cout<<a<<endl;
    // m1;
    for(int i=0;i<N;i++){
      cin>>b;
      max_v=max(max_v,b);
      min_v=min(min_v,b);
      sum += b;
      // cout<<sum<<endl;
       }
    sum = sum - max_v - min_v;
    cout<<sum / ( N -2)<<endl;
    max_v=-1;
    min_v=1000;
    sum =0;
  }
  return 0;

}

C++: #include <iostream>
using namespace std;
int N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
 Max=0;
 Min=1000;
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<N; ++j){
	if(A[j]>Max) Max=A[j];
    }
  for (int k=0; k<N; ++k){
	if(A[k]<Min) Min=A[k];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
  Sum=0;
 }
}

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

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

using namespace std;

int main(){
	while(true){
		int n; cin >> n;
		if(n==0)break;

		vector<int> j(n);
		for(int i = 0; i < n; ++i)cin >> j[i];
		sort(j.begin(), j.end());
		int ans = 0;
		for(int i = 1; i < n-1; ++i){
			ans += j[i];
		}
		ans /= j.size()-2;
		cout << ans << endl;
	}
	return 0;
}

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;
}