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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int n;
  int score[SIZE];
  
  scanf("%d",&n);

  if(n == 0) return false;
  
  for(int i=0;i<n;i++){
    scanf("%d",score+i);
  }

  sort(score, score+n);

  int sum = 0;

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

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

  return true;
}

int main(){

  while(solve());
  
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
    int n,s[100],m=100000,M=0,sum=0;
    cin >> n;
        if(n==0)break;
    for(int i=0;i<n;i++)    cin >> s[i];
    for(int i=0;i<n;i++){
        sum+=s[i];
        m=min(m,s[i]);
        M=max(M,s[i]);
    }
    cout << (sum-M-m)/(n-2)<<endl;
    }
    return 0;
}

C++: #include <iostream>

int main()
{
  int n, s;
  while(std::cin >> n && n > 0){
    int average = 0;
    int max = 0;
    int min = 1000;
    for(int i=0; i<n; i++){
      int tmp;
      std::cin >> tmp;
      if(tmp > max){ max = tmp; };
      if(tmp < min){ min = tmp; };
      average += tmp;
    }
    average -= (max + min);
    std::cout << (average / (n - 2)) << std::endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int n;
long int ans;
int main() {
  for(;;) {
    scanf("%d", &n);
    if(n == 0) break;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) scanf("%d", &v[i]);
    sort(begin(v), end(v));
    v[n - 1] = 0, v[0] = 0;
    for(int i = 0; i < n; ++i) ans+=v[i];
    ans /= n - 2;
    printf("%ld\n", ans);
    n = 0, ans = 0;
    v.clear();
  }
  return 0;
}

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

int main(){
	while(true){
		int n,sum=0;
		list<int> score; 
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			int tmp;
			cin>>tmp;
			score.push_back(tmp);
		}
		score.sort();
		score.pop_back();
		score.pop_front();
		for(list<int>::iterator it=score.begin();it!=score.end();++it)sum+=*it;
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

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

int main() {
int i,n,x,y,a[20],ans;
	while(1){
		scanf("%d",&n);
		if(n == 0)break;
		x = 0;
		y = 0;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		if(a[x] < a[i])x = i;
		if(a[y] > a[i])y = i;
		}
		ans = 0;
		for(i=0;i<n;i++){
			if(i == x)continue;
			if(i == y)continue;
			ans += a[i];
		}
		ans = ans / (n-2);
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
using namespace std;


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

C++: #include <bits/stdc++.h>
using namespace std;
int a[1010];

int main() {
    while(true) {
        int n; cin >> n;
        if(n == 0) break;
        for(int i=0; i<n; ++i) cin >> a[i];
        sort(a, a + n);
        int sum = 0;
        for(int i=1; i+1<n; ++i) sum += a[i];
        cout << sum / (n - 2) << '\n';
    }
}

C++: #include<iostream>
using namespace std;cat 
int n,sum,max,min;
int main(){
	while(cin>>n&&N>0){
		int S;
		sum=0;
		for(int i=0;i<n;i++){
			cin>>S;
			sum+=S;
			if(min>S){
				min=S;
			}
			if(max<S){
				max=S;
			}
		}
		sum-=(min+max);
		cout<<sum/n<<endl;
	}
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	while(1){
		int a;
		cin >> a;
		if(a==0){
			break;
		}
		vector<int> judge(a);
		rep(i, 0, a) cin >> judge[i];
		sort(judge.begin(), judge.end());
		int sum = judge[1];
		rep(i,2,a-1){
			sum += judge[i];
		}
		cout << sum / (a - 2) << "\n";
	}
	return 0;
}

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

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

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

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

using namespace std;

int main(int, char**){
	int n;
	vector<int> ret;
	while(true){
		int n,buf;
		vector<int> scores;
		cin >> n;
		if(n == 0) break;

		for(int i = 0; i < n; ++i){
			cin >> buf;
			scores.push_back(buf);
		}
		scores.erase(max_element(scores.begin(),scores.end()));
		scores.erase(min_element(scores.begin(),scores.end()));
		ret.push_back( std::accumulate(scores.begin(), scores.end(), 0) / scores.size() );
	}

	for(int av : ret){
		cout << av << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n, i, p;
while(cin>>n,n){
int min=1000,max=0,total=0;
for(int i=0;i<n;++i){
cin >> p;
if(p>max)max=p;
if(p<min)min=p;
total += p;
}
cout << (total-max-min)/(n-2) << "\n";
}
}

C++: #include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <bitset>
#include <tuple>

using namespace std;

int main(void)
{
  while (true) {

    int n;
    cin >> n;
    if (n == 0) break;
    int p[n];
    for (int i = 0; i < n; i++)
      cin >> p[i];
    int top,bottom,sum;
    top = -1;
    bottom = 1001;
    sum = 0;
    for (int i = 0; i < n; i++) {
      if (top < p[i])
	top = p[i];
      if (bottom > p[i])
	bottom = p[i];
    }
    
    bool t, b;
    t = b = true;
    for (int i = 0; i < n; i++) {
      if (top == p[i] && t) {
	t = false;
      }
      else if (bottom == p[i] && b) {
	b = false;
      }
      else
	sum+=p[i];
    }
int ans = sum/(n-2);
    cout << ans << endl;
    
  }
  return 0;	
}