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;

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

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

  while(true) {
    int n;
    cin >> n;
    vector<int> v;
    int a;
    rep(i, n) {
      cin >> a;
      v.push_back(a);
    }
    sort(ALL(v));

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

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

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

using namespace std;

int main() {
    int n;

    while(cin >> n, n) {
        vector<int> judge(n);
        int sum = 0;

        REP(i, n) {
            cin >> judge[i];
        }
        sort(judge.begin(), judge.end());

        REP(i, n-2) {
            // cout << judge[i+1] << endl;
            sum += judge[i+1];
        }
        cout << (sum/(n-2)) << endl;

    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    while (1) {
        int n;
        cin >> n;
        if (!n) return 0;

        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        int sum = 0;
        for (int i = 1; i < n - 1; ++i) {
            sum += a[i];
        }
        cout << sum / (n - 2) << "\n";
    }
}

C++: // Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int S[100];

		int sum = 0;

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

		sort(S, S+n);

		cout << (sum-S[0]-S[n-1])/(n-2) << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
const int INF = 1e9;


int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    vector<int> a(n);
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    sort(a.begin(),a.end());
    a.erase(a.end()-1);
    a.erase(a.begin());
    int sum=0;
    for(int i=0;i<a.size();i++){
      sum+=a[i];
    }
    cout<<sum/a.size()<<endl;
  }
  return 0;
}

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

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

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector<int> scores;
        repeat(i, n) {
            int s; cin >> s;
            scores.push_back(s);
        }
        int max_s, min_s;
        max_s = *max_element(scores.begin(), scores.end());
        min_s = *min_element(scores.begin(), scores.end());
        int sum = -max_s-min_s;
        repeat(i, n) {
            sum += scores[i];
        }
        int average = sum / (n-2);
        cout << average << endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main () {

  while (true){

    int n;
    int i;
    int s = 0;
    int mi = 0;
    int ma = 0;
    cin >> n;

    if (n == 0)
      break;
??????
??????int p[100];

    for (i = 0;i < n;i++){
      cin >> p[i];

      if (p[i] < mi)
        mi << p[i];

      if (p[i] > ma)
        ma << p[i];

      s += p[i];

    }

    cout << (s - mi - ma) / (n-2) << endl;

  }

  return 0;

}

C++: #include <iostream>
using namespace std;
int N, S;
int main () {
  while (cin >> N && N>0) {
    int sum = 0;
    int largest = 0;
    int smallest = 1000;
    for (int i=0; i<N; ++i) {
      cin >> S;
      sum += S;
      if (largest < S) largest = S;
      if (smallest > S) smallest = S;
    }
    int average = (sum - largest - smallest) / (N-2);
    cout << average << endl;
  }
}

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<iostream>
using namespace std;

int n,s[100];
int temp,ave,sum;

void sort(void){
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      if(s[i]>s[j]){
	temp=s[i];
	s[i]=s[j];
	s[j]=temp;
      }
    }
  }
}

int main(){
  while(cin >> n,n){
    for(int i=0;i<n;i++)
      cin >> s[i];  
    
    sort();
    
    sum=0;

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

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

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

int main() {
  
  int n, sum, ave;
  while (cin >> n) {
    vector<int> vec(n);
    for (int i=0; i < vec.size(); i++) {
      cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    if (vec.size() > 2) {
      for (int i=1; i<n-1; i++) {
        sum += vec[i];
      }
      ave = sum / (n-2);
    cout << ave << endl;
    }
    sum = 0;
    ave = 0;

  }
}

C++: #include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    while(true){
        int n;
        cin >> n;
        if(n==0) break;
        vector<int> S(n);
        rep(i,n) cin >> S[i];
        int total = accumulate(all(S),0) - *max_element(all(S)) - *min_element(all(S));
        double ave = total / (S.size()-2);
        int iave = floor(ave);
        cout << iave << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    int i,j,in[100],hum,ans,mx=0,mn=1000;
    for(;scanf("%d",&hum),hum!=0;)
    {
        for(i=0,mx=0,mn=1000,ans=0;i<hum;i++)
        {
            scanf("%d",&in[i]);
            mx=mx<in[i]?in[i]:mx;
            mn=mn>in[i]?in[i]:mn;
            ans+=in[i];
        }
        ans=ans-(mn+mx);
        printf("%d\n",ans/(hum-2));
    }
    return 0;
}