Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		n, _ := strconv.Atoi(sc.Text())
		scores := make([]int, n, n)
		for i := 0; i < n; i++ {
			sc.Scan()
			scores[i], _ = strconv.Atoi(sc.Text())
		}
		sort.IntSlice(scores).Sort()
		var sum = 0
		for i := 1; i < n-1; i++ {
			sum += scores[i]
		}
		fmt.Println(sum / (n - 2))
	}
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,s,m,M,ans;
	cin>>n;
	m = 1005;
	M= -1;
	ans=0;
	for(int i=0;i<n;i++){
		cin>>s;
		m=min(m,s);
		M=max(M,s);
		ans+=s;
	}
	n-=2;
	ans=ans-M-m;
	ans /= n;
	cout<<ans<<endl;

}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(x) x.begin(),x.end()


void solve(){
    int N;cin>>N;
    if(N==0)exit(0);
    vector<int>A(N);
    REP(i,N)cin>>A[i];
    sort(ALL(A));
    int sum = 0;
    FOR(i,1,N-1)sum+=A[i];
    cout<<sum/(N-2)<<endl;
}
signed main(){
    while(true){
        solve();
    }
}

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

int main()
{
	int in,a,maxer=0,miner=1000;
	int sum=0;
	int i=0;
	double ave=0.0;
	while( scanf("%d",&in) !=0 ){
		for(i=0; i<in; i++){
			cin >> a;
			maxer=max(a,maxer);
			miner=min(a,miner);
			sum += a;
		}
		sum = sum - maxer - miner;
		ave = sum/(in-2);
		cout << floor(ave) << endl;
		sum = maxer = ave = 0;
		miner=1000;
	}
}

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

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

C++: #include <iostream>
using namespace std;
int main(){
	while(true){
		int n;
		cin >> n;
		if(n==0){
			break;
		}
		const int MAXN=100;
		int a[MAXN];

		for(int i=0; i<n; i++){
			cin >> a[i];
		}
		int max=a[0], min=a[0], kei=0;
		for(int i=0; i<n; i++){
			if(max < a[i]){
				max=a[i];
			}
			if(min > a[i]){
				min=a[i];
			}
			kei+=a[i];
		}
		int heikin;
		heikin=(kei-max-min)/(n-2);
		cout << heikin << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) {
			break;
		}
		int max = -1, min = 1001;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			int m;
			cin >> m;
			sum += m;
			if (max < m) {
				max = m;
			}
			if (m < min) {
				min = m;
			}
		}
		sum -= (max + min);
		sum /= n - 2;
		cout << sum << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	vector<int> array;
	vector<int> ans;
	int i,x,max,min,sum,n;
	max = 0;
	min = 1000;

	while(1){
	cin>>n;
	if(n==0){
		for(i=0;i<sizeof(ans);i++){
			cout<<ans[i]<< endl;
		}

		break;
	}
	array.clear();
	sum=0;

	for(i=0;i<n;i++){
		cin >> x;
		array.push_back(x);
	}
	for(i=0;i<n;i++){
		if(max<array[i]){
			max= array[i];
		}
	}
	for(i=0;i<n;i++){
		if(min>array[i]){
			min= array[i];
		}
	}
	for(i=0;i<n;i++){
		sum += array[i];
	}
	sum = sum-max-min;
	ans.push_back(sum/(n-2));  //2ひいた分だけ割る数を減らす 
	}

}

C++: #include<iostream>
using namespace std;
int N,S;

int main() {
	while (cin >> N && N>0) { // By while (), adopt the form of std in 
		int sum = 0;
		int max = 0;
		int min = 0;
		for (int i=0; i<N; i++) {
			cin >> S;
			sum += S; // calculate sum
			if (max < S) max = S; // search max
			if (min > S) min = S; // search min
		}
		int ans;
		ans = (sum-max-min)/(N-2);
		cout << ans << endl;
	}
	return 0;
}

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

using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::sort;

void input(vector<int>& v, int number) {
    for (int i = 0; i < number; i ++) { 
        int value;
        cin >> value;
        v.push_back(value);
    }   
    sort(v.begin(), v.end());
}

void calc(vector<int> v) {
    int total = 0;
    int average;
    int size = v.size();
    for (int i = 1; i < size - 1; i ++) {
        total += v[i];
    }   
    average = total / (size - 2); 
    cout << average << endl;
}

int main(void) {
    int number;
    cin >> number;
    while (number != 0) {
        vector<int> v(0);
        input(v, number);
        calc(v);
        cin >> number;
    }   
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>



using namespace std;



int main()
{
	int n, s, sum;
	
	while (cin >> n)
	{
		if (n == 0) break;
		
		vector<int> vi;
		for (int i=0; i<n; i++)
		{
			cin >> s;
			vi.push_back(s);
		}
		
		sort(vi.begin(), vi.end());
		
		/*
		//テスト出力
		for (int i=0; i<vi.size(); i++)
		{
			cout << vi[i] << endl;
		}
		*/
		
		sum = 0;
		for (int i=1; i<vi.size()-1; i++)
		{
			sum += vi[i];
		}
		
		cout << sum / (vi.size() - 2) << endl;
	}
	
	return 0;
}

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;
    if(n == 0) break;
    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 <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int n, cmax = 10000, cmin = -1;
  int sum=0;
  while(cin >> n, n){
    REP(i,n){
      cin >> a ;
      cmax = (cmax,a);
      cmin = (cmin,a);
      sum += a;
    }
    cout << (sum-cmax-cmin)/(n-2) << endl;
  }
  return 0;
}