Go: package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int n,s[100];

int main()
{
        scanf("%d",&n);
        if (n==0) return 0;
        for (int i=0;i<n;i++){
                scanf("%d",s+i);
        }
        sort(s, s+n);
        int k=0;
        for (int i=1;i<n-1;i++){
                k+=s[i];
        }
        k/=n-2;
        printf("%d\n",k);
        main();
}

C++: #include<iostream> 
using namespace std; 
int main(){ 
  int n; 
  int t[100],mx,mn,sum; 
  while(1){ 
    cin>>n; 
    if(n==0)break; 
    mx=sum=0; 
    mn=1000; 
    for(int i=0;i<n;i++){ 
      cin>>t[i]; 
      if(mn>t[i])mn=t[i]; 
      if(mx<t[i])mx=t[i]; 
      sum+=t[i]; 
    } 
    sum-=mn; 
    sum-=mx; 
    cout<<sum/(n-2)<<endl; 
      
  } 
  return 0; 
}

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

using namespace std;

void solve(int n){
  list <int> s;
  for(int i = 0 ; i < n ; i++ ){
    int a;
    cin >> a;
    s.push_back(a);
  }
  
  int s_max = 0;
  int s_min = 0xFFFF;
  list<int>::iterator s_max_it;
  list<int>::iterator s_min_it;

  for(auto it = s.begin() ; it != s.end() ; it++ ){
    if(*it > s_max){
      s_max = *it;
      s_max_it = it;
    }
    if(*it < s_min){
      s_min = *it;
      s_min_it = it;
    }
  }
  
  s.erase(s_max_it);
  s.erase(s_min_it);

  int sum = 0;
  for(auto it = s.begin() ; it != s.end() ; it++ ){
    sum += *it;
  } 
  cout << sum / (n-2) << endl;
  return;
}

int main(){
  
  while(1){
  
  int n;
  cin >> n;
  
  if(n > 0)
    solve(n);
  else
    break;

  }

  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,a[1000],c;
	while(true){
		cin>>n;
		if(n==0){
			break;
		}
		c=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		sort(a,a+n);
		for(int i=1;i<n-1;i++){
			c+=a[i];
		}
		cout<<c/(n-2)<<endl;
	}
	return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	int tem;
	int sum;


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

		sum=0;
		vector<int> v;
		for(int i1=0; i1<n; i1++){
			cin>>tem;
			v.push_back(tem);
			sum+=tem;
		}
		sort(v.begin(), v.end());
		sum-=(v[0]+v[v.size()-1]);
		cout<<sum/(n-2)<<endl;
		
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n; //審判の数

    while(true){
        int s[1010]; //各審判のつけた点数
        cin >> n;
        if(n == 0) break;

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

        int max = 0, min = 1000; //点数の最小値、最大値
        for(int i = 0; i < n; i++){
            if(s[i] > max) max = s[i];
            if(s[i] < min) min = s[i];
        }

        int sum = 0; //最高点と最低値を除いた点数たちの和
        int mean; //最高点と最低値を除いた点数の平均値
        for(int i = 0; i < n; i++){
            sum += s[i];
        }
        mean = (sum - max - min) / (n - 2);

        cout << mean << endl;
    }
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

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


    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif
template <class C>
inline void vcin(C &a);
template <class C>
inline void vcout(const C a, const string separate = "\n");

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (n == 0)
    {
      break;
    }
    vector<int> s(n);
    vcin(s);
    sort(s.begin(), s.end());
    s.erase(s.begin());
    s.pop_back();
    cout << accumulate(s.begin(), s.end(), 0) / s.size() << endl;
  }
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C>
inline void vcout(const C c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}