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 <unordered_map>
#include <unordered_set>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;


int main () {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;
		vector<int> v;
		int count = 0;

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

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

int main(void){
  
   

   
   


}

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

int main(void){
    int n, i, tmp, sum_, max_, min_;
    while(true){
        scanf("%d", &n);
        if(n == 0) break;
        min_ = 1001;
        max_ = -1;
        sum_ = 0;
        for(i = 0; i < n; i++){
            scanf("%d", &tmp);
            sum_ += tmp;
            min_ = min(min_, tmp);
            max_ = max(max_, tmp);
        }
        sum_ = sum_ - max_ - min_;
        printf("%d\n", sum_/(n-2));
   }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int n, s[1000],i,max=0,min=1000,sum=0,lastsum;

	while (1){
		max = 0;
		min = 1000;
		sum = 0;

		scanf("%d", &n);
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			scanf("%d", &s[i]);
			sum += s[i];
		}
		for (i = 0; i < n; i++){
			if (max <= s[i]){
				max = s[i];
			}
			for (i = 0; i < n; i++){
				if (min >= s[i]){
					min = s[i];
				}
			}
			lastsum = sum - max - min;
			printf("%d\n", lastsum / (n - 2));
		}
	}
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

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

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

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

using namespace std;

int main(){
    int n;
    int res[20];
    int numres = 0;
    while(1){
        cin >> n;
        if(n==0){
            break;
        }
        
        int max = INT_MIN;
        int min = INT_MAX;
        int total = 0;
        int read;
        for(int i=0; i<n; i++){
            cin >> read;
            total += read;
            if(read < min){
                min = read;
            }
            if(read > max){
                max = read;
            }
        }
        res[numres] = (total - max - min)/(n-2);
        numres++;
    }

    for(int i=0; i< numres; i++){
        cout << res[i] << endl;
    }

    return 0;
}

C++: 
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<stack>
using namespace std;


int main(){
    int n;
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        int sum=0,max=0,min=1000,point;
        for(int i=1;i<=n;i++){
            scanf("%d",&point);
            if(point>max) max=point;
            else if(point<min) min=point;
            sum+=point;
        }
        printf("%d\n",(sum-max-min)/(n-2));
    }
    
    return 0;
}

C++: #include<iostream>
#include<fstream>
#include<vector>
#include<algorithm> //???????????¨

using namespace std;

int main(){
	//ifstream fin("in.txt");

	vector<int> v;

	int average = 0;

	int n = 0;
	while (true){

		cin >> n;
		if (n == 0)break;

		//?????????
		average = 0;
		if (!v.empty())v.clear();

		for (int i = 0; i < n; i++){
			int tmp = 0;
			cin >> tmp;
			v.push_back(tmp);
		}
		sort(v.begin(), v.end());
		v.pop_back();
		v.erase(v.begin());

		for (int i = 0; i < v.size(); i++)
			average += v[i];

		average /= v.size();

		cout << average << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;

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

C++: 

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

float mean(vector<float> v) {
    int size = v.size();
    float sum = 0;
    for (int i = 0; i < size; i++){
        sum += v[i];
    }
    return sum / size;
}

int main(){

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

		vector<float> data(N);

		rep(i,data.size()){
			cin >> data[i];
		}

		sort(data.begin(),data.end());
		
		data.pop_back();
		data.erase(data.begin());

		cout << int(mean(data)) << endl;
	}

	return 0;
}

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

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

C++: #include <iostream>
using namespace std;
int N,S;
int set = 0;
int main(){
  while(set <= 20){
    //while(cin >> N && N >= 3 && N <= 100) {
    cin >> N;
    if (N == 0) break;
    int largest = 0;
    int smallest = 1000;
    int sum = 0;
    for (int i = 0; i <N;++i) {
      cin >> S;
      if(largest < S) largest = S;
      if(smallest >S) smallest = S;
      sum += S;
    }
    cout << (sum - largest - smallest)/(N-2) << endl; 
  ++set;
  }
  return 0;
}

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

using namespace std;
int N, S;
int main() {
  while (cin >> N && N > 0) {
    int sum = 0;
    int m = 1001;
    int M = -1;
    for (int i = 0; i < N; ++i) {
      cin >> S;
      sum += S;
      m = min(m, S);
      M = max(M, S);
    }
    sum = sum - m - M;
    int ans = sum / (N-2);
     cout << ans << endl;
  }
  return 0;
}

C++: #include<cstdio>

bool solve(){
	int n,ma = 0,mi = 1000,sum = 0;
	scanf("%d",&n);
	if(n==0) return false;
	for(int i=0;i<n;i++){
		int s;
		scanf("%d",&s);
		if(s<mi) mi = s;
		if(s>ma) ma = s;
		sum += s;
	}
	printf("%d\n",(sum-ma-mi)/(n-2));
	return true;
}

int main(){
	while(solve()){}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n, s, maxn, minn;

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

    maxn=0;
    minn=1000;
    int x=0;
    for(int i=0;i<n;i++){
      scanf("%d", &s);
      x+=s;
      maxn=max(s,maxn);
      minn=min(s,minn);
    }

    printf("%d\n",(x-maxn-minn)/(n-2) );
  }
  return 0;
}