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 REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s, n = 0;
    int mx = 0, mn = 0, sum = 0;
    while (1)
    {
        cin >> n;
        mx = -1;
        mn = 1001;
        sum = 0;
        if (n == 0)
            return 0;
        REP(i, n)
        {
            cin >> s;
            mx = max(mx, s);
            mn = min(mn, s);
            sum += s;
        }
        cout << (sum - mx - mn) / (n - 2) << endl;
    }
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

int main() {
  int n;
  vector<int> r;

  while (true) {
    cin >> n;
    if (n == 0) break;
    int sum = 0;
    int max = -1;
    int min = 1001;
    REP(i, n) {
      int val;
      cin >> val;
      if (val > max) max = val;
      if (min > val) min = val;
      sum += val;
    }
    sum = sum - max - min;
    r.push_back((int)(sum / (n - 2)));
  }
  REP(i, r.size()) { cout << r[i] << endl; }
  return 0;
}

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

int main() {
	int n;
	while (cin >> n) {
		if (n == 0)break;
		int a[n];
		int ans = 0;
		for (int i = 0;i < n;i++) {
			cin >> a[i];
			ans += a[i];
		}
		sort(a, a + n);
		ans -= a[0] + a[n - 1];
		ans /= n - 2;
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int n=100,input=100;
    while (1){
        scanf("%d", &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 <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
  
int main()
{

	int sum=0;
	int n;
	int max;
	int min;
	int i;
	int m;


	while(1)
	{
	scanf("%d",&n);
	if(n==0)
		break;

	max=0;
	min=1000;
	sum=0;

	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		sum+=m;
		if(m>max)
			max=m;
		if(m<min)
			min=m;
	}

	sum = sum-max-min;

	printf("%d\n",(sum/(n-2)));
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cassert>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;


int n,s[200];

/*
input data
*/

void init(){
}

bool input(){
	cin>>n;
	if(n==0) return false;
	for(int i=0; i<n; i++) cin>>s[i];
	return true;
}


void swap(){
	int tmp;
	for(int i=0; i<n; i++){
		for(int j=n-1; j>i; j--){
			if(s[j-1]>s[j]){
				tmp=s[j-1];
				s[j-1]=s[j];
				s[j]=tmp;
			}
		}
	}
}



int solve(){
	int sum=0, ans=0;
	swap();
	for(int i=1; i<n-1; i++){
		sum+=s[i];
	}
	ans=sum/(n-2);
	return ans;
}


int main(){
  while(input()){
    cout<<solve()<<endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <numeric>
#include <climits>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm> 

/*
	メモ
	#inlucde <string>
	memset(配列,初期化値,sizeof(配列));//配列初期化

	#include <queue>
	push(),back(),front()
	pop()//最初の要素削除

	#inclue <stack>
	pop(),push(),top(),empty()

	__builtin_popcount(unsigned int);

*/

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{"; for(auto nth : list){ cout << nth << " ";}cout << "}" << endl;

using namespace std;

int main() {

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

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

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int n;

  int tensu[200];

  while(cin>>n,n){
	cout << n << endl;//
  int max = 0;
  int min = 1000;
  int sum=0;
	REP(i,n){
	  cin >> tensu[n];
	  sum+=tensu[n];
	  if(max<tensu[n])
		max=tensu[n];
	  if(min>tensu[n])
		min=tensu[n];
	}

	//cout<<min<<endl<<max<<endl<<sum<<endl;//

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

  }

}

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

int main() {
    int n; cin >> n;
    while (n != 0) {
        int max_s = 0, min_s = 1000, sum_s = 0;
        for (int i = 0; i < n; ++i) {
            int s; cin >> s;
            max_s = max(max_s, s);
            min_s = min(min_s, s);
            sum_s += s;
        }
        int ans = (sum_s - max_s - min_s) / (n - 2);
        cout << ans << endl;
        
        cin >> n;
    }
    return 0;
}

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

C++: #include<iostream>
using namespace std;
int N,S,max,min;

int main() {
	while (cin >> N && N>0) { // By while (), adopt the form of std in 
		int sum = 0;
		max = 0;
		min = 0;
		for (int i=0; i<N; i++) {
			cin >> S;
			sum += S; // calculate sum
			if (max < S) max = S; // search max
			if (min > S) min = S; // search min
		}
		int ans = (sum-max-min)/(N-2);
		cout << ans << endl;
	}
}

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

using namespace std;

const int MAX_N = 110;

int judge_num;
int score[MAX_N];

//---------------------//                                                                                            
int main()
{
        while (cin >> judge_num) {

                if (judge_num == 0) break;

                for(int i = 0; i < judge_num; ++i) {
                        cin >> score[i];
                }

                sort(score, score + judge_num);

                int ave;
                double sum_temp = 0;

                for (int i  = 1; i < judge_num - 1; ++i) {
                        sum_temp += score[i];
                }

                ave = (int)( floor( sum_temp / (judge_num - 2) ) );

                cout << ave << endl;
        }

        return 0;
}

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

int main() {
	int n,point,sum,ma,mi;
	
	while(cin>>n){
		if(n==0)break;
		sum=0;
		ma=0;
		mi=1000;
		for(int i=0;i<n;i++){
			cin>>point;
			sum+=point;
			if(ma<point)ma=point;
			if(mi>point)mi=point;
		}
		cout<<(sum-ma-mi)/(n-2)<<endl;;
			}
	
	
	return 0;
}