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())
		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 < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include<stdio.h>

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

C++: #include <bits/stdc++.h>
using namespace std;

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

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include<climits>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int getAverageScore(int N, VI S){
	int min = S[0];
	int max = S[0];
	int sum = 0;
	FOR(i, 1, N){
		sum += S[i];
		if (min > S[i]){ min = S[i]; }
		if (max < S[i]){ max = S[i]; }
	}
	sum -= (min + max);
	return sum / N;
}
int main(){
	int N;
	VI S;
	int b;
	int c = INT_MAX;
	while (true){
		cin >> N;
		if (N == 0){ break; }
		if (c != INT_MAX){ cout << endl; }
		REP(i, N){
			cin >> b;
			S.push_back(b);
		}
		c = getAverageScore(N, S);
		cout << c;
		S.clear();
	}
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;

int main(){
	int n;
	while(1){
		int i,sum=0,a=0,max=0,min=0,s=0;
		cin>>n;
		if(n==0)break;
		cin>>sum;
		max=sum;min=sum;
		for(i=1;i<n;i++){
			cin>>a;
			sum+=a;
			if(min>a)min=a;
			if(max<a)max=a;
		}
		s=(sum-max-min)/(n-2);
		cout<<s<<endl;
	}
    return 0;
}

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

int main(int argc, char const* argv[])
{
  while (true) {
    int n;
    std::cin >> n;
    if (n == 0) {
      break;
    }
    std::vector<int> scores(n);
    for (int i = 0; i < n; ++i) {
      int s;
      std::cin >> s;
      scores[i] = s;
    }
    std::sort(scores.begin(), scores.end());
    scores.erase(scores.begin());
    scores.pop_back();
    int sum = std::accumulate(scores.begin(), scores.end(), 0);
    std::cout << (sum / (n - 2)) << std::endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    while(cin >> n){
        if(n == 0) break;
        vector<int> A(n);
        REP(i, n) cin >> A[i];
        sort(A.begin(), A.end());
        if(n - 2 <= 0){
            cout << 0 << endl;
            continue;
        }
        int total = 0;
        REP(i, n - 1){
            if(i) total += A[i];
        }
        cout << total / (n - 2) << endl;
    }

    return 0;
}

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

using namespace std;
int main() {
	int n;
	while (cin >> n && n) {
		int sum = 0;
		int ln = 100000;
		int hn = 0;
		for (int i = 0; i < n; ++i) {
			int d;
			cin >> d;
			ln = min(d, ln);
			hn = max(hn, d);
			sum += d;
		}
		cout << (sum - hn - ln) / (n - 2) << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int n;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(true){
		cin >> n;
		if(n == 0) return 0;
		vector<int> v;
		for(int i=0; i<n; ++i){
			int t;
			cin >> t;
			v.push_back(t);
		}
		int sum = 0;
		sort(v.begin(), v.end());
		for(int i=1; i<n-1; ++i)
			sum += v[i];
		sum /= n-2;
		cout << sum << "\n";
	}
}

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

int main()
{
    int x;
    while(1){
        cin >> x;
        if(x == 0) break;
        int max = -1, mini = 10000, sum = 0, score = 0, y = 0;
        for(int i = 0; i < x; i++){
           cin >> score;
          sum += score;
          if(score > max) max = score;
            if(score < mini) mini = score;
        }
        sum -= max + mini;
        y = sum / (n - 2);
        cout << y << endl;
    }
    return 0;
}

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

int main(){
  while( cin >> N && N > 0){ //N??????????????????????????????????????§while????????????
    int sum = 0; 
    int min = 1001; //min????°?????????¨?????????
    int max = -1;
    int average = -1;

    for (int i = 0; i < N; i++){
      cin >> S;
      sum += S;
      if( S > max ) max = S;
      if(S < min) min = S; 
    }

    average = (sum - min - max) / N - 2; //???N-2?????§???????????¨?????¨??????

    cout << average << endl;
  }

  return 0;
}

C++: import math
import copy

def average(points):
    sum = 0
    for i in points:
        sum += i
    return sum / len(points)

outputs = []

while True:
    num = int(input())
    if num == 0:
        break

    points = []
    for _ in range(num):
        point = int(input())
        points.append(point)

    points = sorted(points)
    points = points[1:len(points)-1]

    ave = average(points)
    outputs.append(int(ave))

for ave in outputs:
    print(ave)

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

int main(){
	int n;
	while(cin >>n){
		if(n == 0) break;
		vector<int> vec;
		int tmp, max, min;
		cin >>tmp;
		vec.push_back(tmp);
		max = tmp;
		min = tmp;
		bool maxb = true, minb = true;
		for(int i = 1; i < n; i++){
			cin >>tmp;
			vec.push_back(tmp);
			if(tmp < max) max = tmp;
			if(tmp > min) min = tmp;
		}
		int sum = 0;
		for(int i = 0; i < vec.size(); i++){
			if(vec[i] == max && maxb){
				maxb = false;
			} else if(vec[i] == min && minb){
			minb =false;
		} else{
			vec[i] += sum;
		}
		cout <<sum <<endl;
		return 0;
	}
}
}