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 <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int n;
    vector<int> vi;
    while (cin >> n, n) {
        vi.clear();
        for (int i = 0; i < n; i++) {
            int s;
            cin >> s;
            vi.push_back(s);
        }
        sort(vi.begin(), vi.end());
        cout << accumulate(vi.begin()+1, vi.end()-1, 0) / (n-2) << endl;
    }
    return 0;
}

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

int main(){
    int a,n;
    for(;;){
        vector<int> num;
        cin>>n;
        if(n==0) break;
        for(int i = 0; i < n; i++){
            cin>>a;
            num.push_back(a);
        }
        sort(num.begin(), num.end());
        num.erase(num.begin());
         num.pop_back();
        int sum=0;
        for(int x : num){
            sum+=x;
        }
        sum/=num.size();
        cout<<sum<<endl;
    }
    return 0;
}

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

int main() {
  int n, s;
  int v[110];

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

  return 0;
}

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

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

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

int main() {
	int n, i, p[100], t = 0;
	int max = 0, min = 1000, maxi, mini;
	cin >> n;
	
	for (i = 0; i < n; i++) {
		cin >> p[i];
	}

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

		if (p[i] > max) {
			maxi = i;
			max = p[i];
		}

		if (p[i] < min) {
			mini = i;
			min = p[i];
		}
	}

	cout << (t - p[maxi] - p[mini]) / (n - 2) << endl;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
 
int main() {
    int n, data;
    while(1) {
        scanf("%d", &n);
        if (n == 0) break;
        int sum=0, max=0, min=1001;
        for (int i=0; i<n; i++) {
            scanf("%d", &data);
            sum+=data;
            if (max < data) max=data;
            if (data < min) min=data;
        }
        printf("%d\n", (sum-max-min)/(n-2));
    }
}

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

using namespace std;

int main()
{

  while(1)
  {
	 int n;

	 cin >> n;
 
	 if(n == 0)break;

	 int Max = 0; 
	 int Min = 1001;
	 int Sum = 0;

	 for(int i = 0;i < n;i++)
	 {
	   int tmp;
	   cin >> tmp;
	   Sum += tmp;
	   Max = max(tmp,Max);
	   Min = min(tmp,Min);
	 }

	 Sum = Sum - Max - Min; 

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

  return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;
 
int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int max = 0, min = 1000, sum = 0, score, ans;
        for(int i = 0; i < n; i++){
            cin >> score;
            sum += score;
            if(score > max) max = score;
            else if(score < min) min = score;
        }
        sum -= max + min;
        ans = sum / (n - 2);
        cout << ans << endl;
    }
    return 0;
}

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

int input_count_trial() {
    int count;
    std::cin>>count;
    return count;
}

void display(int count_trial) {
    std::vector<int> scores;
    int score;
    for(int i=0; i<count_trial; i++) {
        std::cin>>score;
        scores.push_back(score);
    }
    std::sort(scores.begin(), scores.end());
    scores.erase(scores.begin());
    scores.erase(scores.end()-1);
    int sum = std::accumulate(scores.begin(), scores.end(), 0);
    int avarage = sum/(scores.size());
    std::cout << avarage << std::endl;
    return;
}

int main() {
    int count_trial = input_count_trial();
    do {
        display(count_trial);
        count_trial = input_count_trial();
    }while(count_trial!=0);
    return 0;
}

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

int main(){


  int n;

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

    //テ・ツ?・テ・ツ環?
    int point[200];
    for(int i = 0; i < n ; i++){
      cin >> point[i];
      //      cout << point[i] << " ";
    } 

    //max
    int max = -1;
    for(int i = 0 ; i < n ; i++){
      if(point[i] > max)
	max = point[i];
    }
    for(int i = 0 ; i < n ; i++){
      if(point[i] == max){
	point[i] = -1;
	break;
      }
    }

    //min
    int min = 10000;
    for(int i = 0 ; i < n ; i++){
      if(point[i] < min && point[i] != -1 )
	min = point[i];
    }
    for(int i = 0 ; i < n ; i++){
      if(point[i] == min){
	point[i] = -1; 
	break;     
      }
    }

    int ans = 0;
    for(int i = 0; i < n ; i++){
      if(point[i] > -1)
	ans += point[i];
      //  cout << point[i] << " ";
    }
    ans = ans / (n-2);
    cout << ans << endl;

  }

  return 0;
}