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;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// Aliases
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int sum = 0, smn = INT_MAX, smx = INT_MIN;
        REP(i, n) {
            int s;
            cin >> s;
            sum += s;
            smn = min(smn, s);
            smx = max(smx, s);
        }
        cout << (sum - smn - smx) / (n - 2) << "\n";
    }

    return 0;
}

C++: #include <iostream>
#include <limits.h>

#define el endl
#define fd fixed

using namespace std;

int main() {
  while (1) {
    int n;
    cin >> n;
    int m = n;
    if (n == 0) break;
    int max = INT_MIN;
    int min = INT_MAX;
    int ave = 0;
    while (m--) {
      int x;
      cin >> x;
      ave += x;
      if (x < min) min = x;
      if (x > max) max = x;
    }
    ave = ave - (max + min);
    ave = ave / (n-2);
    cout << ave << el;
  }
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int sum = 0, x, total, ans;
  vector<int> p(0);
  int n;
  
    while(1){
      cin >> n;
      if(n==0)
      break;
      for(int i=0; i<n; i++){
        cin >> x;
        p.push_back(x);
      }

      int max = *max_element(p.begin(), p.end());
      int min = *min_element(p.begin(), p.end());

      for(int i=0; i<n; i++){
        sum += p[i];
      }
      total = sum - min - max;
      ans = total / (n-2);
      cout << ans << endl;
    }

  return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>=0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = 3.141592653589793;
int n;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    while (n!=0) {
        int  s[105]={};
        rep(i,n) cin >> s[i];
        sort(s,s+n);
        int ans=0;
        rep2(i,1,n-1) ans+=s[i];
        cout << ans /(n-2) << endl;
        cin >> n;
    }
    return 0;
}

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

int main(){
  int n,maxn,minn,ave,sum = 0;

  while(cin >> n){
    if(n == 0) break;
    
    int *s = new int[n];

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

      if(s[maxn]  <= s[i]){
	maxn = i;
      }
      if(s[minn] >= s[i]){
	minn = i;
      }

      
    }

    for(int i=0; i<n ; ++i){
      if(i != maxn && i != minn){
	sum += s[i];
      }
    }


    
    ave = sum/(n - 2);

    cout << ave << endl;

    sum = 0;
    ave = 0;
    
    delete[] s;
  }
  
  
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0)return 0;
    vector<int> a(n);
    for(int i=0;i<a.size();i++){
      cin >> a[i];
    }
    sort(a.begin(),a.end());
    int sum =0;
    for(int i=1;i<(a.size()-1);i++){
        sum+=a[i];
      }
    int avg = sum/(n-2);
    cout << avg << endl;
  }
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef vector<int> vi;

int main(){
	int n;
	while(cin >> n, n){
		vi v(n);
		rep(i, n){
			cin >> v[i];
		}
		sort(all(v));
		int sum = 0;
		for(int i = 1; i < n-1; i++){
			sum += v[i];
		}
		cout << sum/(n-2) << endl;
	}

	return 0;
}

C++: #include<stdio.h>

int sum(int x[], int n)
{
  int a, t_sum=0;
  for(a=1; a<n-1; a++)
    {
      t_sum+=x[a];
    }
  return t_sum;
}


int main(void)
{
  int count=0, check=0, i=0,k=0, avg[10]={0};

  while(1)
    {
      int  temp=0, score[100]={0};
      scanf("%d", &count);
      if(count==0)
	{

	  for(i=1;i<=k;i++)
	    {
	      printf("%d\n", avg[i]);
	    }
	  return 0;
	}
      else
	{
	  k++;
	  for(i=0; i<count; i++)
	    {
	      scanf("%d", &check);
	      score[i]=check;
	    }
int t, j, temp;

  for(t=0;t<count-1;t++)
    {
      for(j=count-1;j>t; j--)
	{
	  if(score[j-1]>score[j])
	    {
	    temp=score[j];
	  score[j]=score[j-1];
	  score[j-1]=temp;
	    }
	}
    }
	  temp=sum(score,count);

	  avg[k]=temp/(count-2);
	  
	}
    }

}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<int> s(n);
    for (int i = 0; i < n; i++){
      cin >> s[i];
    }
    sort(s.begin(), s.end());
    int sum = 0;
    for (int i = 1; i < n - 1; i++){
      sum += s[i];
    }
    cout << sum / (n - 2) << endl;
  }
}

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

int main()
{
	int n,m,i;
	int ave[1000]={0};

	m=0;
	while(1){
		int point[100]={0};
		int min=1000;
		int max=0;
		cin>>n;
		if(n==0) break;
		for(i=0;i<n;i++){
			cin>>point[i];
			if(point[i]>max) max=point[i];
			if(point[i]<min) min=point[i];
			ave[m]+=point[i];
		}
//		cout<<"debug "<<ave[m]<<endl;
//		cout<<max<<" "<<min<<endl;
		ave[m]=(ave[m]-max-min)/(n-2);
		m++;
	}
	for(i=0;i<m;i++){
		cout<<ave[i]<<endl;
	}
}

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

// hona method

int main()
{
	while(1)
	{
		int judges;
		int scores[1024];
		int total = 0;

		::scanf("%i", &judges);

		if(judges == 0)
		{	break;	}
		
		for(int j = 0; j < judges; j ++)
		{
			::scanf("%i", &scores[j]);
		}

		std::sort(scores, scores + judges);

		/*for(int j = 0; j < judges; j ++)
		{
			::printf("%i\n", scores[j]);
		}*/
		for(int j = 1; j < judges - 1; j ++)
		{
			total += scores[j];
		}
		printf("%i\n", total / (judges - 2));
	}
}