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

int main(){
    int n;
    int high,low;
    int hi,lo;
    int total;
    int cnt;
    int point[100]={0};
    while(1){
        total = 0;
        cnt = 0;
        cin >> n;
        if(n == 0) break;
        for(int i=0;i<n;i++){
            cin >> point[i];
            if(i == 0){
                high = point[i];
                low = point[i];
                hi = 0;
                lo = 0;
            }
            else if(point[i] > high){
                high = point[i];
                hi = i;
            }
            else if(point[i] < low){
                low = point[i];
                lo = i;
            }
        }
        for(int i=0;i<n;i++){
            if(i != hi && i != lo){
                total += point[i];
                cnt++;
            }
        }
        cout << total / cnt << endl;
    }
}

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

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

    int sum = 0, minv = 100000, maxv = -1;
    for (int i = 0; i < n; i++) {
      int s;
      cin >> s;
      if (s < minv) minv = s;
      if (s > maxv) maxv = s;
      sum += s;
    }
    sum -= minv + maxv;
    int ave = sum / (n - 2);
    
    cout << ave << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		vi 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)<<endl;
	}
}

C++: #include <iostream>
#include<algorithm>
using namespace std;
int main() {
	while (true) {
		int n;
		cin >> n;
		int sum = 0;
		int ma = 0;
		int mi = 100000;
		for (int i = 0; i < n; i++) { int s; cin >> s; sum += s; ma = max(ma, s); mi = min(mi, s); }
		cout << (sum - mi - ma) / (n - 2) << endl;
	}
}

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

int main()
{
	int n;
	while (cin >> n, n) {
		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;
	}
	
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>

using namespace std;
const int INF = (1<<30);
typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)

int sx, sy;

int gx, gy;

int qqq;

//各座標までの最短距離
int d[100][100];


//移動方向のベクトル
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

//汎用
ll ans = 0;
pair<int, int> red[101], blue[101];
ll BIG = 10000000000;

//累乗
ll POW(ll a, ll b) {
ll c = 1;
for (int i = 0; i < b; ++i) {
c *= a;
}
return c;
}

//階乗
int Kaijou(int a) {
if (a < 2) return 1;
return a * Kaijou(a - 1);
}


int A[200000];
int kinds[200001];


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

		vector<int> s(n);
		rep(i, n) cin >> s[i];
		sort(s.begin(), s.end());
		int sum = 0;
		for (int i = 1; i < n - 1; ++i)
			sum +=s[i];
		int ave = sum / (n - 2);
		cout << ave << endl;
	}
	cin >> qqq;
}

C++: #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;
ll mod2 = 998244353;

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

C++: #include <stdio.h>
int main() {
    for(int x=0;x<1000;x++){
	int a = 0;
	scanf("%d", &a);
	int g[1000] = {};
	for (int i = 0; i < a; i++) {
		scanf("%d", &g[i]);
	}
	int sd = 0;
	int ss = 0;

	sd = g[1];
	ss = g[1];
	for (int i = 0; i < a; i++) {
		if (g[i] > sd) {
			sd = g[i];
		}
		if (g[i] < ss) {
			ss = g[i];
		}
	}
	int g1 = 0;
	for (int i = 0; i < a; i++) {
		g1 = g1 + g[i];
	}
	int g2 = 0;
	g2 = g1 - sd - ss;
	a = a - 2;
	g2 = g2 / a;
	if(g2==0){
	    
	}else {
	printf("%d\n", g2);
	}
}
return 0;
}

C++: #include<stdio.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);

void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                   
    j = right;                  

    pivot = x[(left + right) / 2];
    while (1) {                   

        while (x[i] < pivot)      
            i++;                  

        while (pivot < x[j])      
            j--;                  
        if (i >= j)               
            break;                

        Swap(x, i, j);            
        i++;                      
        j--;
    }

    if (left < i - 1)              
        QSort(x, left, i - 1);     
    if (j + 1 <  right)            
				QSort(x, j + 1, right);    
		}

void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(void)
{
	int i;
	int j;
	int k;
	int n;
	int d[20];
	int p[100];
	int sum;
	int ave;
	
	while(1){

		scanf("%d",&n)
		if(n==0) break;
		
		for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		}

		QSort(p,0,n-1);	
	
		sum = 0;
		for(i=1;i<n-1;i++)
			sum += p[i];
	
			j = 0;
			d[j] = sum / (n-2);
			j++;
	}
	
	for(k=0;k<j;k++){
		printf("%d",d[k]);
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int larger(int x,int y) {
	int z = 0;
	if (x > y)z = x;
	else z = y;
	return z;
}
int smaller(int x, int y) {
	int z = 0;
	if (x < y)z = x;
	else z = y;
	return z;
}
int main(void) {
	int sinsa,a[100],sum=0,ave;
	cin >> sinsa;
	for (int i = 0; i < sinsa; i++) {
		cin >> a[i];
	}
	int n = a[0];
	for (int i = 0; i < sinsa; i++) {
		n = larger(n, a[i]);
	}
	int m = a[0];
	for (int i = 0; i < sinsa; i++) {
		m = smaller(m, a[i]);
	}
	for (int i = 0; i < sinsa; i++) {
		sum += a[i];
	}
	sum = sum - n - m;
	ave = sum / (sinsa - 2);
	cout << ave;
	return 0;

}

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

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