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<bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int n;
    while (cin >> n , n){
        vector<int> a(n);
        REP(i,n) cin >> a[i];
        sort(ALL(a));
        int sum = 0;
        for (int i=1; i<n-1; i++) {
            sum += a[i];
        }
        cout << sum/(n-2) << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  ll N;
  ll s[1100];
  ll sum=0;
cin>>N;
  while(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;
  cin>>N;
  }
}
}

C++: # include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;


int main() {
  int n;

  while (cin >> n) {
    if (!n) break;

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

    int  sum = 0;
    int _max = scr[0];
    int _min = scr[0];

    for (int s : scr) {
      sum  += s;
      _min = min(_min, s);
      _max = max(_max, s);
    }

    sum -= _max;
    sum -= _min;

    cout << sum / (n-2) << endl;
  }

  return 0;
}

C++: #include <stdio.h>
#include <algorithm>

int main() {
	int a[100];
	int n, s, i, j, sum;

	scanf("%d",&n);

	while(true) {
		sum = 0;
		if(n == 0)break;
		for(i = 0; i < 100; i++) {
			a[i] = 1000;
		}	
		for(i = 0; i < n; i++) {
			scanf("%d",&s);
			a[i] = s;
		}
		std::sort(a,a+100);
		for(j = 1; j < n-1; j++) {
			sum = sum + a[j];
		}
		printf("%d\n",sum/(n-2));
		scanf("%d",&n);
	}
	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];
                }
                cout << endl;           
        
                //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];
                        else if (a[j] < smallest)
                                smallest = a[j];
                }
                
                //average
                int average = 0;
                average = (sum - largest - smallest) / (i - 2);
                cout << average;
        }

C++: #include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    int n;
    while( true ){
        cin >> n;
        if (n == 0) break;
        int a[n];
        for(int i=0;i<n;i++)cin>>a[i];
        sort(a,a+n);
        for(int i=2;i<n-1;i++)a[1]+=a[i];
        cout<<a[1]/(n-2)<<endl;
    }   
    return 0; 
}

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

int main()
{
	int n;

	while(true){
		std::cin >> n;
		if ( n == 0 ) break;

		std::vector<int> v(n,0);

		for ( int i = 0; i < n; ++i ) {
			std::cin >> v[i];
		}

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

		int sum = 0;
		for ( int i = 1; i < n-1; ++i ) {
			sum += v[i];
		}
		std::cout << sum / (n-2) << std::endl;
	}
	return 0;
}

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

int main(){
    int n,s,avg;
    while (cin>>n && n!=0){
        int sum=0,ma=0,mi=1000;
        for (int i=0;i<n;i++){
            cin>>s;
            sum+=s;
            ma=max(ma,s); //最大値の更新
            mi=min(mi,s); //最小値の更新
        }
        avg=(sum-ma-mi)/(n-2); //平均の計算
        cout<<avg<<endl;
    }
}

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

using namespace std;

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0)return 0;
		int b[100];
		for (int i = 0; i < n; i++)cin >> b[i];
		sort(b, b + n);
		int res = 0;
		for (int i = 1; i < n - 1; i++)res += b[i];
		cout << res/(n-2) << endl;
	}
}

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

const int LLINF = 1LL << 60;


signed main()
{
  int N;

  while(cin >> N, N) {
    int maxv = -LLINF, minv = LLINF;
    int sum = 0, A;
    Rep(i, N) {
      cin >> A; sum += A;
      maxv = max(maxv, A), minv = min(minv, A);
    }

    sum -= maxv + minv;

    cout << sum / (N - 2) << endl;
    
  }

  return 0;
}

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

int main(){
	int n;
	int j[110];
	int max,min;
	for(;cin>>n,n!=0;){
		for(int i=0;i<n;i++){
			cin>>j[i];
		}
		max=min=0;
		int sum=0;
		for(int i=0;i<n;i++){
			if(max<j[i])max=j[i];
			if(min>j[i])min=j[i];
			sum+=j[i];
		}
		sum-=max+min;
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	int N, S;
	while(cin >> N && N>0){
		int largest = 0;
		int smallest = 1001;
		int sum = 0;
		for (int i = 0;i<N;i++){
			cin >> S;
			largest = max(largest,S);
			smallest = min(smallest,S);
			sum += S;
		}
		sum = sum - largest;
		sum = sum - smallest;
		cout << sum /(N-2) << endl;
	}
	return 0;
}

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

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

vector<int> x;

void init(){
  x.clear();
}
bool input(){
  int n;
  cin>>n;
  if(n==0)return false; 
 rep(i,n){
    int a;
    cin>>a;
    x.push_back(a);
  }
  return true;
}

int solve(){
  sort(x.begin(),x.end());
  int sum = 0;
  reps(i,1,x.size()-1)sum+=x[i];
  return sum/(x.size()-2);
}
int main(){
  while(init(),input()){
    printf("%d\n",solve());
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
const int INF = (1<<30);

int main()
{
  int n;
  while( cin >> n, n ) {
    int ma = 0, mi = INF, sum = 0, data;

    for(int i=0; i<n; i++) {
      cin >> data;
      sum += data;
      if( data > ma ) ma = data;
      if( data < mi ) mi = data;
    }
    
    sum = sum - ma - mi;
    cout << sum / (n-2) << endl;
  }

}

C++: #include <iostream>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main()
{
	int n;
	while(cin >> n,n){
		int s[100];

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

		sort(s,s+n);

		int sum = 0;
		for(int i = 1; i < n-1; i++)
			sum += s[i];

		cout << sum / (n-2) << endl;
	}
	return 0;
}