Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		if n == 0 {
			break
		}
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < len(scores)-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

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


int main() {
  int n;

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

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

using namespace std;

int main()
{
	int n;
	int s[101];
	int sum;
	
	while(scanf("%d", &n), n != 0){
		sum = 0;
		for (int i = 0; i < n;i++) scanf("%d", &s[i]);
		
		sort(s, s + n);
		
		for (int i = 1; i < n-1; i++){
			sum += s[i];
		}
		
		printf("%d\n", sum/(n-2));
	}
}

C++: #include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;

int main(){
  int n;
  while(scanf("%d", &n) && n){
    int lmin = 9999, lmax = 0, sum = 0, s;
    rep(i, n){
      scanf("%d", &s);
      lmin = min(lmin, s); lmax = max(lmax, s);
      sum += s;
    }

    printf("%d\n", (sum - lmin - lmax) / (n-2));
  }
  return 0;
}

C++: #include <stdio.h>

int main(){

  int i,n,sum=0,min=1000,max=0,ave=0,x,l;
  int score[101];

  for(;;){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=1;i<=n;i++){

      scanf("%d",&score[i]);

      if(max<score[i]){
	max=score[i];
	x=i;
      }

      if(min>score[i]){
	min=score[i];
	l=i;
      }
    }


    score[l]=0;
    score[x]=0;


    for(i=1;i<=n;i++){
      sum+=score[i];
    }
    ave=sum/(n-2);

    printf("%d\n",ave);

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

  }
  return 0;
}

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