Go: package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		num := nextInt(sc)
		if num == 0 {
			break
		}

		score_list := []int{}
		for i := 0; i < num; i++ {
			score_list = append(score_list, nextInt(sc))
		}
		// 得点リストをソートした後、最低点と最高点を取り除く(3 ≤ n ≤ 100)
		sort.Sort(sort.IntSlice(score_list))
		score_list = score_list[1 : len(score_list)-1]
		// 得点リストの得点を合計し、スライスの個数で割って平均点を出す
		sum := 0
		for _, score := range score_list {
			sum += score
		}
		fmt.Println(sum / len(score_list))
	}
}

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, 0, N){
		sum += S[i];
		if (min >= S[i]){ min = S[i]; }
		if (max <= S[i]){ max = S[i]; }
	}
	sum -= min;
	sum -= max;
	return sum / (N-2);
}
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 <iostream>
#include <cmath>
using std::cin;
using std::cout;
using std::endl;


int main(){
  int n;
  int k;
  int sum=0;
  int max;
  int min;
  while(cin >> n){
    sum = 0;
    if(n == 0){
      break;
    }
    for(int i = 0;i < n;i++){
      cin >> k;
      if(i==0){
        min = k;
        max = k;
      }else if(min > k){
        min = k;
      }else if(max < k){
        max = k;
      }
      sum += k;
    }
    sum = (sum - min - max)/(n-2);
    cout << sum << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define endl '\n'
const int INF = (1 << 30);
using namespace std;
typedef long long int ll;

bool solve(){
    int n, smax=0, smin=INF, sum=0, s;
    cin >> n;
    if(!n) return false;
    REP(i,n){
        cin >> s;
        smax = max(s, smax);
        smin = min(s, smin);
        sum += s;
    }
    cout << (sum - smin - smax) / (n-2) << endl;
    return true;
}

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

    while(solve());
}

C++: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;

int main() {
  vector<int> stack;

  while (true) {
    int count;
    cin >> count;
    if (count == 0) { break; }
    vi point(count);
    for (int i = 0 ; i < count ; i++) {
      cin >> point[i];
    }
    sort(point.begin(), point.end());
    int ave = 0;
    for (int i = 1 ; i <= point.size()-2 ; i++) {
      ave += point[i];
    }
    ave /= (count-2);
    stack.push_back(ave);
  }

  for (int i = 0 ; i < stack.size() ; i++) {
    printf("%d\n", stack[i]);
  }

  return 0;
}

C++: #include <iostream>

using namespace std;
int main(){
	int N;
	int* score;
	int S;
	int max = 0;
	int min = 0;
	
	cin >> N;
	score = new int[N];
	for(int i=0; i<N; ++i){
		cin >> score[i];
		S += score[i];
		
		if( max < score[i] ){
			max = score[i];
		}
		if( min > score[i] ){
			min = score[i];
		}
	}
	S -= max;
	S -= min;
	
	cout << (int)S/(N-2) << endl;

	delete[] score;
	return 0;
}

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

int main(){
	int n, s, sum, maxs, mins, i;
	while((cin >> n), n){
		sum = maxs = 0;
		mins = 1000;
		for(i = 0; i < n; i++){
			cin >> s;
			sum += s;
			maxs = max(maxs, s);
			mins = min(mins, s);
		}
		sum = (sum - maxs - mins) / (n - 2);
		cout << sum << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<list>
using namespace std;
bool b[33000];
int main() {	
	int n;
	while (cin >> n&&n) {
		int a=10000000, b=-100,x;
		long long sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> x;
			sum += x;
			a = min(a, x);
			b = max(b, x);
		}
		sum -= a;
		sum -= b;
		double c = (double)sum / (double)n - 2;
		cout << c << endl;
	}
}

C++: #include<bits//stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n&&n!=0){
		int a[100];
		for(int i=0;i<n;i++) cin>>a[i];
		sort(a,a+n);
		int sum=0;
		for(int i=1;i<n-1;i++){
			sum+=a[i];
		}
		sum/=floor((n-2));
		cout<<sum<<endl;
	}
}

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

using namespace std;

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

        int max_s = 0, min_s = 1000, sum = 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;
        }

        int res = (sum - min_s - max_s) / (n - 2);
        cout << res << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
//---------------------------------------------------------------------------//
int n,sum=0;
int a[10000];
int main(){
        cin>>n;
        for(int i=0; i<n; i++) {
                cin>>a[i];
        }

        sort(a,n);
        for(int i=1; i<n-1; i++) {
                sum+=a[i];
        }
        cout<<sum/(n-2)<<endl;
}