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 <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;
			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++){
			rep(i, it->second){
				result += it->first;
				factor++;
			}
		}

		cout << result / factor << endl;
	}
	

	return 0;
}

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

using namespace std;

int main()
{
	int n;

	while (scanf("%d", &n), n){
		vector<int> v;

		for (int i = 0; i < n; i++){
			int s;

			scanf("%d", &s);

			v.push_back(s);
		}

		sort(v.begin(), v.end());

		v[0] = v[n - 1] = 0;

		int sum = 0;

		for (int i = 0; i < n; i++){
			sum += v[i];
		}

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

	return (0);
}

C++: #include <iostream>
using namespace std;
int main(){
    int a, b, c, d, max, min;
    
    while(1){c = 0;
        max = 0;
        min = 2000000000;
        cin >> a;
        if(a == 0){break;}
        for(int i=0;i<a;i++){
            cin >> b;
            if(b>max){
                max = b;
            }
            if(b<min){
                min = b;
            }
            c = c + b;
        }
        c = c - max - min;
        d = c / (a-2);
        cout << d << endl;
    }
    
    
    
    
    
    
    return 0;

}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int n;
  int point[20], average;
  
  while(1){
    average = 0;
    cin >> n;
    if(n < 3) break;

    for(int i = 0 ; i < n ; i++){
      cin >> point[i];
    }
    sort(point, point + n);
    for(int i = 1 ; i < n - 1 ; i++){
      average += point[i];
    }
    average /= (n-2);
    cout << average << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
	int n = -1;

	vector<int> score;

	while (true)
	{
		int sum = 0;

		cin >> n;

		if (n == 0) { break; }

		vector<int> D(n);

		for (int i = 0; i < n; ++i)
		{
			cin >> D[i];

			sum += D[i];
		}

		sum -= *max_element(D.begin(), D.end());
		sum -= *min_element(D.begin(), D.end());

		score.push_back(static_cast<int>(sum / (D.size() - 2) + 0.5));
	}

	for (int i = 0; i < score.size(); i++)
	{
		cout << score[i] << endl;
	}

	return 0;
}

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

int main()
{
	int N, n, sum, largest, smallest;
	sum  = 0; largest = 0; smallest = 1000;
	
	while(cin >> N && N>0){
		for(int i = 0; i<N; i++)
		{
			cin >> n;
			sum += n;
			
			if(smallest > n){ smallest = n;}
			if(largest < n){ largest = n;}
		}
	
		cout << (sum-smallest-largest)/(N-2) << endl;
	}
}

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

int main() {
int i,n,x,y,a[20],ans;
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		x = 0;
		y = 0;
		ans = 0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		if(a[x] < a[i])x = i;
		if(a[y] > a[i])y = i;
			ans += a[i];
		}
		ans = ans - a[x] - a[y];
		ans = ans / (n-2);
		printf("%d\n",ans);
	}
	return 0;
}

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

int main(){
        int i = 0;
        
        while(cin >> i && !(i == 0)){
                int a[i];
                int j = 0;              

                for(j=0; j<i; j++){
                        cin >> a[j];
                }
        
                //sum
                int sum = 0;
                for (j=0; j<i; j++) {
                        sum += a[j];
                }
        
                //largest,smallest
                int largest = 0;
                int smallest = 1000;
                for (j=0; j<i; j++){
                        if (a[j] > largest)
                                largest = a[j];
                        if (a[j] < smallest)
                                smallest = a[j];
                }
                
                //average
                int average = 0;
                average = (sum - largest - smallest) / (i - 2);
                cout << average << endl;
        }

}

C++: #include <iostream>

int main()
{

    while(1) {
        int judgeNum = 0;
        int pointSum = 0;
        int maximumPoint = 0;
        int minimumPoint = 1000;

        std::cin >> judgeNum;
        if (judgeNum == 0) {
            break;
        }

        for(int i = 0; i < judgeNum; i++) {
            int point;
            std::cin >> point;
            if(point > maximumPoint) {
                maximumPoint = point;
            }

            if (point < minimumPoint) {
                minimumPoint = point;
            }
            pointSum += point;
        }

        int answerSum = pointSum - maximumPoint - minimumPoint;

        std::cout << answerSum / (judgeNum - 2) << std::endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<random>
#include<string>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
  ll t=0;
  while(t<=20){
  s++;
  cin >> 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;
}
}

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

using namespace std;

int main(int, char**){
	int n;
	vector<int> ret;
	while(0){
		int n,buf;
		vector<int> scores;
		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; ++i){
			cin >> buf;
			scores.push_back(buf);
		}
		ret.push_back(accumulate(scores.begin(), scores.end(), 0) / scores.size());
	}

	for(int av : ret){
		cout << av << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

typedef vector <int> VI;
typedef vector <VI> VVI;
typedef vector <string> VS;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, LL> PIL;
typedef vector <PIL> VPIL;


#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define sort(c) sort((c).begin(),(c).end())

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

#define MAX_INT 2147483647

int main(){
	int n, s, total;
	int max_s, min_s;
	while (1){
		cin >> n;
		if (!n) break;
		total = 0; max_s = 0; min_s= 1000; 
		rep(i,n){
			cin >> s;
			total += s;
			max_s = max(s, max_s);
			min_s = min(s, min_s);
		} 
		cout << (total - max_s - min_s) / (n-2) << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	while (1) {
		int n;
		cin >> n;
		if (n == 0)break;
		int M = 0, m = 2525;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int a;
			cin >> a;
			M = max(a, M), m = min(a, m);
			cnt += a;
		}

		cout << (cnt - M - m) / (n - 2) << endl;
	}
	return 0;
}