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 <iostream>
#include<stdio.h>
using namespace std;
int main(void){
   int n;
   int x[21];
   while(1){
       int max=-1,min=1001;
       int S=0;
       cin>>n;
       if(n==0){
           break;
       }
       for(int i=0;i<n;i++){
            cin>>x[i];
            if(min>x[i]){
                min=x[i];
            }
            if(max<x[i]){
                max=x[i];
            }
           S=S+x[i];            
       }
       cout<<(S-(max+min))/(n-2)<<endl;
   }
   return 0;
}

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

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

using namespace std;

int main(){
  int n;
  while(cin>>n,n!=0){
    vector<int> score(n);
    rep(i,n)cin>>score[i];

    vector<int>::iterator minIt = min_element(score.begin(),score.end());
    int minIndex = distance(score.begin(),minIt);
    score.erase(score.begin()+minIndex-1);

    vector<int>::iterator maxIt = max_element(score.begin(),score.end());
    int maxIndex = distance(score.begin(),maxIt);
    score.erase(score.begin()+maxIndex-1);

    int sum = accumulate(score.begin(),score.end(),0);
    cout << sum/score.size() << endl;
  }
  return 0;
}

C++: #include <iostream>
#define INF (2<<29)
using namespace std;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    for(;;){
        int a,n,s=0,max=0,min=INF;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            s+=a;
            if(max<a) max=a;
            if(min>a) min=a;
        }
        cout<<(s-max-min)/(n-2)<<endl;
    }
    return 0;
}

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

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef complex<int> P;
typedef pair<int,int> pii;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
template <class F, class T> void convert(const F &f, T &t){	stringstream ss; ss << f; ss >> t;}


bool solve(int n){
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>> a[i];
	
	sort(all(a));
	int ans = 0;
	for(int i=1;i<n-1;i++) ans += a[i];
	ans /= n-2;
	
	cout<< ans<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed); cout.precision(10);
	int n;
	while(cin>> n, n){
		solve(n);
	}
	return 0;
}

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

using namespace std;

#define MAX 100

int n, s[MAX];

int main() {
	while (1) {
		scanf("%d", &n);
		if (n == 0)
			return 0;

		for(int i = 0; i < n; i++)
			scanf("%d", s + i);
		sort(s, s + n);

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

		printf("%d\n", ans / (n - 2));
	}
}

C++: #define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		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 <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int solve(int );

int main(void){
  int N;

  while(1) {
    cin>>N;
    if(N==0) return 0;
    else solve(N);
  }
  return 0;
}

int solve(int N){
  vector<int> score(N);
  FOR(i,0,N){
    cin>>score[i];
  }
  sort( score.begin(),score.end() );

  int sum;
  FOR(i,1,N-1){
    sum += score[i];
  }
  int ans = sum/(N-2);
  cout<<ans<<endl;
  sum=0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

int main(void) {
	int N;
	while (cin >> N, N) {
		vector<int> score(N);
		for (int i = 0; i < N; i++)
			cin >> score[i];
		sort(score.begin(), score.end());
		
		int sum = 0;
		for (vector<int>::iterator it = score.begin() + 1; it != score.end() - 1; it++)
			sum += *it;
		int avg = sum / (N - 2);

		cout << avg << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int i,N,total=0,maxdayo,mindayo,box[1000];
  while(1){
  cin>>N;
  if(N==0) break;
  else{
  for(i=0;i<N;i++){
    cin>>box[i];
  }
  maxdayo=0;
  mindayo=1000;
  for(i=0;i<N;i++){
    total+=box[i];
    maxdayo=max(box[i],maxdayo);
    mindayo=min(box[i],mindayo);
  }
  total=total-maxdayo-mindayo;
  cout<<total/(N-2)<<endl;
  }
  total=0;
  }
  return 0;
}

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

int N, S;

int main()
{
   while ( cin >> N && N>0)
   {
      int M, m, addup, i;
      M = -1;
      m = 1001;
      addup = 0;
      for ( i = 0; i<N; i++)
      {
         cin >> S;
         addup += S;
         if ( S > M) M = S;
         if ( S < m) m = S;
      }
   cout << (addup - M - m)/(N-2)  << endl;
   }
}