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 <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	while(cin>>n,n)
	{
		int t;
		cin>>t;
		int s=t,mi=t,ma=t;
		for (int i = 1; i < n; ++i)
		{
			cin>>t;
			s+=t;
			mi=min(mi,t);
			ma=max(ma,t);
		}
		cout<<(s-ma-mi)/(n-2)<<endl;
	}
	return 0;
}

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

int main(){
	int n, s, sum, maxs, mins, i;
	while((cin >> n), n){
		sum = maxs = 0;
		mins = 1000;
		for(i = 0; i < n; i++){
			cin >> s;
			sum += s;
			maxs = max(maxs, s);
			mins = min(mins, s);
		}
		cout << (int)((sum - maxs - mins) / n) << endl;
	}
}

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

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

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

void slove(int s){
	vint v(s);
	rep(i, s) scanf("%d", &v[i]);

	sort(all(v));
	ll sum = 0;
	for (int i = 1; i < s - 1; ++i)
	{
		sum += v[i];
	}
	
	printf("%lld\n", sum / (s - 2));
	return;
}

int main(void){

	int s;
	cin >> s;
	while(s != 0){
		slove(s);//???????????°
		cin >> s;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
    int n, s;
    while (cin >> n && n) {
        int mx = -1;
        int mn = 1001;
        int sum = 0;
        for (int i=0; i<n; ++i) {
            cin >> s;
            sum += s;
            mx = max(mx, s);
            mn = min(mn, s);
        }
        sum = sum - mx - mn;
        cout << sum / (n - 2) << endl;
    }
    return 0;
}

C++: int main()
{
    int n;
    while(1){
        cin >> x;
        if(x == 0) break;
        int max = -1, mini = 10000, sum = 0, ten = 0, y = 0;
        for(int i = 0; i < x; i++){
            cin >> ten;
            sum += ten;
           
            if(ten < mini) mini = ten;
	    if(ten > max) max = ten;
        }
        sum -= max + mini;
        y = sum / (x - 2);
        cout << y << endl;
    }
    return 0;
}

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

}

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

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

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

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 sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

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

		VI a;
		rep(i, n) {
			int x; cin >> x;
			a.pb(x);
		}
		int min = *min_element(all(a));
		int max = *max_element(all(a));
		int ans = (accumulate(all(a), 0) - min - max) / (n - 2);
		cout << ans << endl;
	}
}

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

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

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

int main() {
    int n;

    while (true) {
        cin >> n;
        if (!n) break;
        bool bMax = false;
        bool bMin = false;
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            int t; cin >> t;
            if (bMax == false && t >= 1000) bMax = true;
            else if (bMin == false && t <= 0) bMin = true;
            else sum += t;
        }
        cout << sum/(n-bMax-bMin) << endl;
    }
}

C++: #include <iostream>
using namespace std;
int main() {
    int N,input;
    while (1){
        cin >> N;
        if (N==0){
            break;
        }
        int sum=0,max=0,min=1001;
        for (int i;i<N;i++) {
            cin >> input;
            sum = sum+input;
            if (max < input) max = input;
            if (min > input) min = input;
        }
        cout << (sum-max-min)/(N-2) <<endl;
    }
}